开发者

IE and Chrome caches 'no-cache' images

开发者 https://www.devze.com 2023-04-12 02:55 出处:网络
Hi I\'m using fragment caching extensively in my rails application. 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 e

Hi I'm using fragment caching extensively in my rails application. 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" ).

Im using amazon s3 for storage and the expires header for the images is "no-cache". Sample image URL : https://s3.amazonaws.com/bucket_name/avatars/388/th开发者_运维问答umbs

In IE and Chrome, Im facing a peculiar problem. 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. 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.

e.g. s3.amazonaws.com/bucket_name/avatars/388/thumbs/filename.jpg?1230601161

0

精彩评论

暂无评论...
验证码 换一张
取 消