服务器是nginx的,配置了下面这段代码:
location ~* \.(css|js|apk)$ {
root /usr/local/resources;
expires 12h;
}
用chrome访问可以看到js与css都是 from memory cache
与 from disk cache
,然后状态都是 200
。50个请求,1.03秒, 17kb
用firefox访问js与css同样50个请求,但响应是3.x秒2.x秒甚至4.x秒。返回的状态是304
,没有像chrome那样读取缓存。返回的内容有1.87MB,每次都是这样
firefox请求头
Accept: text/css,*/*;q=0.1
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Cache-Control: max-age=0
Connection: keep-alive
Cookie: ID=d450d6f9-434b-4…031709a|1548209034|1548208680
Host: x.xxxx.com
If-Modified-Since: Mon, 21 May 2018 01:41:39 GMT
Referer: https://x.xxxx.com/index.html
User-Agent: Mozilla/5.0 (Macintosh; Intel …) Gecko/20100101 Firefox/57.0
firefox响应
cache-control: max-age=864000
date: Wed, 23 Jan 2019 02:03:54 GMT
etag: "5b0223d3-37e2"
expires: Sat, 02 Feb 2019 02:03:54 GMT
last-modified: Mon, 21 May 2018 01:41:39 GMT
server: Tengine
set-cookie: SERVERID=3e75f47fc0404902213b8…|1548209034|1548208680;Path=/
X-Firefox-Spdy: h2
请问firefox需要设置什么吗? 还是代码有问题?
你是不是在控制台 网络 设置了禁用缓存?