我使用 nginx + thin 托管 redmine,并带有静态内容缓存
问题是:它是否被浏览器缓存?
nginx 缓存配置:
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
# Some basic cache-control for static files to be sent to the browser
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
以下是响应标头:
Request URL:http://redmine/javascripts/prototype.js?1251746896
Request Method:GET
Status Code:304 Not Modified
Request Headers
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Cookie: <hiden>
Host:redmine
If-Modified-Since:Mon, 31 Aug 2009 19:28:16 GMT
Referer:http://redmine/issues/
User-Agent: <someuseragent>
Query String Parameters
1251746896:
Response Headers
Cache-Control:max-age=315360000, public, must-revalidate, proxy-revalidate
Connection:keep-alive
Date:Fri, 09 Dec 2011 01:15:12 GMT
Expires:Thu, 31 Dec 2037 23:55:55 GMT
Last-Modified:Mon, 31 Aug 2009 19:28:16 GMT
Pragma:public
Server:nginx/0.7.67
然而铬审计仍然说:
The following resources are explicitly non-cacheable. Consider making them cacheable if possible:
答案1
即使不需要重新下载内容,至少也要让must-revalidate
浏览器查询资源是否已更改?它将接受“未更改”的响应,但仍然必须查询服务器以获取该响应,而不是直接使用本地缓存的副本。
Chromium 可能将此报告为内容不是完全可缓存的 - 尝试删除重新验证相关的指令,看看有什么区别。