简体   繁体   中英

Rails 3 caching and image_tag

In my rails application I have a feature that allows users to rotate their uploaded images. On the backend I'm simply using ImageMagick's convert to rotate the image.

The problem I have is with the image_tag helper. As I understand it, image_tag adds a timestamp to the end of the file path to aid with browser caching. However, the timestamp isn't changing after applying convert and refreshing the page, so the user doesn't see any change in their image.

I'm thinking this has something to do with the entire view being cached by rails? I'm not sure if that is the case and some time spent on Google didn't really make it clear if that could be the problem.

对于每次加载页面,您都应该能够使图像的URL唯一,这将破坏浏览器缓存:

<%= image_tag "name_of_image.png?#{Time.now.to_f}" %>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM