简体   繁体   English

IE和Chrome缓存“不缓存”图像

[英]IE and Chrome caches 'no-cache' images

Hi I'm using fragment caching extensively in my rails application. 嗨,我在Rails应用程序中广泛使用片段缓存。 I've cached fragments which have user images in them. 我已经缓存了其中包含用户图像的片段。 So when a user changes his/her avatar(image), a lot of fragments have to be expired. 因此,当用户更改他/她的头像(图像)时,许多片段必须过期。 To solve this, I've made some settings so that a user's avatar URL is always constant ( "/avatars/:user_id/thumbs" ). 为了解决这个问题,我进行了一些设置,以使用户的头像URL始终是恒定的(“ / avatars /:user_id / thumbs”)。

Im using amazon s3 for storage and the expires header for the images is "no-cache". 我使用亚马逊s3进行存储,图像的过期标题为“ no-cache”。 Sample image URL : https://s3.amazonaws.com/bucket_name/avatars/388/thumbs 示例图片网址: https//s3.amazonaws.com/bucket_name/avatars/388/thumbs

In IE and Chrome, Im facing a peculiar problem. 在IE和Chrome中,我遇到了一个特殊的问题。 When a user changes his avatar, it is not reflected immiediately on client side. 当用户更改其头像时,不会立即在客户端反映出来。 It takes 2-3 page refresh for the image to change. 更改图像需要2-3页的刷新时间。 Has anyone faced similar issues before? 有人遇到过类似的问题吗?

You're going about this the wrong way in my opinion. 我认为您正在以错误的方式进行操作。 Expire the fragment as you're doing but allow rails' cache busting timestamps to force the browser to download new images. 在执行操作时使片段到期,但允许Rails的缓存清除时间戳记强制浏览器下载新图像。

eg s3.amazonaws.com/bucket_name/avatars/388/thumbs/filename.jpg? 例如s3.amazonaws.com/bucket_name/avatars/388/thumbs/filename.jpg? 1230601161 1230601161

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

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