为什么浏览器没有缓存我的图像?

时间:2014-07-16 11:55:08

标签: caching header

我正在使用nginx和Adaptive Images根据设备分辨率提供动态大小的图像。自适应images.php文件设置的响应头如下所示,但每次刷新页面时,浏览器都会再次请求图像。为什么浏览器不缓存这些图像?浏览器是谷歌浏览器,无论我如何更新,它似乎都在请求标头中设置max-age=0。我尝试了F5,Ctrl + F5并在地址栏中输入了URL并按Enter键。

请求标题:

GET /img/photos/p8.jpg HTTP/1.1
Host: example.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: image/webp,*/*;q=0.8
Pragma: no-cache
If-Modified-Since: Wed, 16 Jul 2014 12:01:31 GMT
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36
Referer: http://example.com/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,en-GB;q=0.6

响应标题:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 16 Jul 2014 12:08:55 GMT
Content-Type: image/jpeg
Content-Length: 391104
X-Powered-By: PHP/5.4.30
Cache-Control: private, max-age=604800
Expires: Wed, 23 Jul 2014 12:08:55 GMT
Last-Modified: Wed, 16 Jul 2014 12:08:55 GMT
Connection: Keep-Alive

1 个答案:

答案 0 :(得分:1)

事实证明,这似乎是Chrome 功能

请参阅其他SO答案原因:Chrome doesn't cache images/js/css