WebPageTest 抱怨即使我启用了缓存也没有缓存静态资源

WebPageTest complaining about not caching static resources even though I have caching enabled

我正在 webpagetest.org 上测试我的网站。它给了我

然后继续给出这个列表:
利用静态资产的浏览器缓存:63/100
警告 -(2.0 小时)- http://stats.g.doubleclick.net/dc.js
警告 -(5.5 天)- http://www.bookmine.net/css/images/ui-bg_highlight-soft_100_eeeeee_1x100.png
警告 -(5.5 天)- http://www.bookmine.net/favicon.ico
警告 -(5.5 天)- http://www.bookmine.net/js/index.min.js
警告 -(5.5 天)- http://www.bookmine.net/js/jquery-ui-1.8.13.custom.min.js
警告 -(5.5 天)- http://www.bookmine.net/css/index.css
警告 -(5.5 天)- http://www.bookmine.net/js/jquery.form.min.js
警告 -(5.5 天)- http://www.bookmine.net/css/jquery-ui-1.8.13.custom.css

有趣的是它确实识别出我启用了缓存(如上所述设置为 5.5 天),那么它在抱怨什么?我还验证了我在 app.yamlthis link:

中设置了 default_expiration: "5d 12h"

default_expiration

Optional. The length of time a static file served by a static file handler ought to be cached by web proxies and browsers, if the handler does not specify its own expiration. The value is a string of numbers and units, separated by spaces, where units can be d for days, h for hours, m for minutes, and s for seconds. For example, "4d 5h" sets cache expiration to 4 days and 5 hours after the file is first requested. If omitted, the production server sets the expiration to 10 minutes.

For example:

application: myapp version: alpha-001 runtime: python27 api_version: 1 threadsafe: true

default_expiration: "4d 5h"

handlers: Important: The expiration time will be sent in the Cache-Control and Expires HTTP response headers, and therefore, the files are likely to be cached by the user's browser, as well as intermediate caching proxy servers such as Internet Service Providers. Once a file is transmitted with a given expiration time, there is generally no way to clear it out of intermediate caches, even if the user clears their own browser cache. Re-deploying a new version of the app will not reset any caches. Therefore, if you ever plan to modify a static file, it should have a short (less than one hour) expiration time. In most cases, the default 10-minute expiration time is appropriate.

我什至在 fiddler 中验证了我的网站返回的响应:

HTTP/200 responses are cacheable by default, unless Expires, Pragma, or Cache-Control headers are present and forbid caching. HTTP/1.0 Expires Header is present: Sat, 26 Sep 2015 08:14:56 GMT

HTTP/1.1 Cache-Control Header is present: public, max-age=475200 public: This response MAY be cached by any cache. max-age: This resource will expire in 132 hours. [475200 sec]

HTTP/1.1 ETAG Header is present: "74YGeg"

那为什么我得了 D?

添加一些有用的 links:
- http://www.learningtechnicalstuff.com/2011/01/static-resources-and-cache-busting-on.html
- http://www.codeproject.com/Articles/203288/Automatic-JS-CSS-versioning-to-update-browser-cach
- https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching#invalidating-and-updating-cached-responses
- https://developers.google.com/speed/docs/insights/LeverageBrowserCaching
-
- http://www.particletree.com/notebook/automatically-version-your-css-and-javascript-files/

如果缓存过期设置少于 30 天,WebPagetest 会发出警告。您可以通过单击测试结果中的 "D" 等级并查看 "Cache Static" 的词汇表来查看详细信息。您还可以找到该信息 here.

如果您需要修改缓存的静态 javascript 文件,您可以将版本号添加到文件路径或查询字符串中。