【发布时间】:2011-06-13 08:08:51
【问题描述】:
我的 Nginx 中有一个资源配置如下:
location ~ foo\.js$ {
add_header Cache-Control public;
expires 1d;
}
如果我用 Firebug 打开它并查看标题,它会显示:
Cache-Control max-age=86400, public
该站点正在使用 HTTPS,因此我想确保它正确,因为显然浏览器不会缓存它,除非它的 max-age>0 AND public。 See this
但是当我使用curl -Ik https://... 时,我的 Nginx 会发生什么情况:
...
Expires: Sat, 22 Jan 2011 18:23:36 GMT
Cache-Control: max-age=86400
Cache-Control: public
...
它重复了Cache-Control 标头!显然 Firebug 并不介意。但这样做对吗?
是否有更好的方法将Expires 和Cache-Control(与public)设置在两行中?
【问题讨论】:
-
您确定需要 max-age 和 public 吗?根据规范 (w3.org/Protocols/rfc2616/rfc2616-sec14.html),第 14.9.3 节指出“响应上的 max-age 指令意味着响应是可缓存的(即“公共”),除非还存在其他一些更严格的缓存指令。 "
标签: nginx cache-control