简体   繁体   English

Rails 3缓存和image_tag

[英]Rails 3 caching and image_tag

In my rails application I have a feature that allows users to rotate their uploaded images. 在我的rails应用程序中,我具有一项功能,允许用户旋转其上载的图像。 On the backend I'm simply using ImageMagick's convert to rotate the image. 在后端,我只是使用ImageMagick的convert来旋转图像。

The problem I have is with the image_tag helper. image_tag的问题是image_tag帮助程序。 As I understand it, image_tag adds a timestamp to the end of the file path to aid with browser caching. 据我了解, image_tag在文件路径的末尾添加了一个时间戳,以帮助浏览器缓存。 However, the timestamp isn't changing after applying convert and refreshing the page, so the user doesn't see any change in their image. 但是,在应用convert并刷新页面后,时间戳不会更改,因此用户看不到图像的任何更改。

I'm thinking this has something to do with the entire view being cached by rails? 我在想这与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. 我不确定是否是这种情况,是否在Google上花费了一些时间并不清楚是否可能是问题所在。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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