为什么浏览器不缓存这些静态文件?

时间:2013-05-07 20:40:48

标签: http browser

这是一个示例JavaScript文件请求/响应:

Request URL:http://local/index.js?time=1367958844038
Request Method:GET
Status Code:200 OK

Request Headers
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
DNT:1
User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31

Response Headers
cache-control:max-age=31536000
content-encoding:gzip
content-type:application/javascript
expires:Wed, 07 May 2014 20:34:04 GMT
last-modified:Tue, 07 May 2013 20:34:04 GMT
transfer-encoding:chunked

正如您所看到的,服务器响应缓存控制,过期甚至最后修改,但每次我用F5重新加载或点击在位置栏中输入时请求看起来都一样(我希望浏览器发送if-modified - 等等。)

至少在Chrome和Firefox中会发生这种情况。

1 个答案:

答案 0 :(得分:1)

可能是因为网址time参数随每个请求而变化。

由于URL不同,浏览器无法使用以前缓存的响应。

相关问题