I have created a image crop facility that I can click on an image and crop it and it saves the new cropped image over the old one, then redirects back to the original page where the image was show.
But it still shows the old image even after a redirect and doesn't display the new one till I refresh the page.
I have tried just using an image tag and removing the asset timestamp after the image but it still displays the old image and I have also tried adding meta tags to stop browser caching but not working.
How can I solve this without having to do a refresh page?
It's probably not the best way, but I've solved this problem in the past by simply appending a timestamp to the image URL using JavaScript:
http://www.mysite.com/img/some_image.jpg?timestamp=12342312412
Next time it loads, the timestamp is set to the current time and the URL is different, so the browser does a GET for the image instead of using the cached version.
Are you using the rails image helper tag: image_tag in your views?
Rails automatically appends a timestamp based on the last modified date of the image file which is handy because it should change when you do your crop and write out the new image.
More information in the docs: http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With