为什么浏览器不缓存这些静态文件? [英] Why are browsers not caching these static files?

查看:302
本文介绍了为什么浏览器不缓存这些静态文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是一个例子JavaScript文件的请求/响应:

Here's an example JavaScript file request/response:

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 - 由于等)

As you can see, the server responds with cache control, expires and even last modified, but everytime I reload with either F5 or clicking enter in location bar the request looks the same (I'd expect browser to send if-modified-since, etc.)

这发生在Chrome和Firefox最少。

This happens in Chrome and Firefox at least.

推荐答案

大概是因为URL的时间参数变化的每个请求。

Probably because the URL's time parameter changes with every request.

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

Since the URL is different, the browser can't use the previously cached response.

这篇关于为什么浏览器不缓存这些静态文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆