图像不缓存? [英] Image Not Caching?
问题描述
我相信,我的网站上的某些图像不正确缓存。我已经设置了头,尽我所能,但它仍然好像他们再次每次我打的刷新按钮时下载。
例如,特定的图像总是位在1秒至下载。这甚至之后的应的缓存。下面是响应头:
HTTP / 1.1 200 OK
日期:孙老师,2011年3月6日12时51分52秒GMT
服务器:Apache / 2.2.17(Unix的)了mod_ssl / 2.2.17的OpenSSL / 0.9.7a mod_auth_passthrough / 2.1 mod_bwlimited / 1.4的FrontPage / 5.0.2.2635 PHP / 5.2.16
上次修改:周四,01 1 1970 00:00:00 GMT
接受-范围:字节
内容长度:19211
缓存控制:最大年龄= 630323456,公共
到期日:周三,2021年3月3日12时51分52秒GMT
保持活动:超时= 5,上限= 98
连接:保持活动
内容类型:图像/ PNG
这有什么错呢?谢谢你。
更新
< FilesMatch\\(HTM |全文| PHP)$。>
头中设置过期星期四,01 1 1970 00:00:00 GMT
< / FilesMatch>
您的Last-Modified说1970年,你的最大年龄是630323456秒(19岁)。因此,该文件自1989年以来过期,并且必须重新下载。浏览器是做什么它应该做的。
解决方案:
-
更改的Last-Modified到的真正的上次修改(可能是一段时间在过去的几年中)
-
改变最大年龄为
-
删除Expires头;当你也有最大年龄它将被重写。 参见RFC2616节14.9.3 。另外,删除Cache-Control头,只保留Expires头。一方是好的,但只使用一个,不是两个人。
I'm convinced that certain images on my site are not caching properly. I have set the headers as best I can, but it still seems like they download again every time I hit the refresh button.
For example, a particular image always takes a bit over 1 second to download. This is even after it should be cached. Here are the response headers:
HTTP/1.1 200 OK
Date: Sun, 06 Mar 2011 12:51:52 GMT
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 PHP/5.2.16
Last-Modified: Thu, 01 Jan 1970 00:00:00 GMT
Accept-Ranges: bytes
Content-Length: 19211
Cache-Control: max-age=630323456, public
Expires: Wed, 03 Mar 2021 12:51:52 GMT
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
Content-Type: image/png
Is there anything wrong with this? Thanks.
UPDATE
<FilesMatch "\.(htm|html|php)$">
Header set Expires "Thu, 01 Jan 1970 00:00:00 GMT"
</FilesMatch>
Your Last-Modified says 1970, and your max-age is 630323456 seconds (19 years). So the file has been 'expired' since 1989, and must be re-downloaded. The browser is doing what it should be doing.
Solution:
Change the Last-Modified to the real Last-Modified (probably some time in the past few years)
Change the max-age to
Remove the Expires header; it is overridden when you also have max-age. See RFC2616 section 14.9.3. Alternatively, delete the Cache-Control header and keep only the Expires header. Either one is fine, but only use one, not both of them.
这篇关于图像不缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!