开发者

How, to prevent image cache by browser?

开发者 https://www.devze.com 2023-01-15 14:23 出处:网络
in myPylons app 开发者_运维问答i write a script to autogenerate thumbnail, from image geting by url.

in my Pylons app 开发者_运维问答i write a script to autogenerate thumbnail, from image geting by url.

To generate thumbnail i use PIL(python)

W wont to prevent image cache by browser.

I can't use after src ?[random_number] because the site, where i past this image must be static.

I try to send headers

response.headers['Cache-Control'] = 'no-store,no-cache, must-revalidate,post-check=0, pre-check=0,max-age=0'

But still don't work, the browser cache this image,

Can anyone help me to resolved this problem?

Thanks in advance.


Traditionally, you need additional headers to catch most browsers, and even then some will still cache it. Even browsers that support the Cache-Control header (which is part of HTTP 1.1) may be connecting through an HTTP 1.0 proxy that strips out nonstandard headers. I'd try also adding an explicit Expires header with the date and time the image is sent (or just a fixed date in the past) and also a Pragma header with the value "no-cache."

response.headers['Cache-Control'] = 'no-store,no-cache, must-revalidate,post-check=0, pre-check=0,max-age=0'
response.headers['Expires'] = 'Wed, 01 Sep 2010 00:00:00 GMT'
response.headers['Pragma'] = 'no-cache'
0

精彩评论

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