我的 application.js 文件名看起来像application-b600352536291bc180983d43e6a2407f.js
. 所以它的名字中有 md5 缓存破坏器。我已将静态资产的 max-age 选项设置为 1 hour config.static_cache_control = "public, max-age=3600"
。但我观察到浏览器不尊重max-age
标头,并且总是从服务器重新验证并为304 Not Modified
. 我怎样才能节省往返行程?
请求标头
Request URL:https://blah.com/assets/application-b600352536291bc180983d43e6a2407f.js
Request Method:GET
Status Code:304 Not Modified
Request Headersview source
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
Cache-Control:max-age=0
Connection:keep-alive
If-Modified-Since:Sun, 12 Feb 2012 07:36:16 GMT
响应标头
Cache-Control:public, max-age=3600
Connection:keep-alive
Date:Sun, 12 Feb 2012 18:27:48 GMT
Last-Modified:Sun, 12 Feb 2012 07:36:16 GMT
Server:nginx
Vary:Accept-Encoding
Via:1.1 varnish
X-Varnish:499878183