利用浏览器缓存的 Google 页面速度建议
好吧,我正在尝试优化我的应用程序,目前为此使用页面速度。最强烈的建议之一是我需要利用浏览器缓存。该报告将我转到此页面:
http ://code.google.com/intl/pt-BR/speed/page-speed/docs/caching.html#LeverageBrowserCaching
在此页面中有这样的引用:
如果上次修改日期是 足够远足够远的过去, 浏览器可能不会重新获取 它。
我的观点是:我为 Last-Modified 标头设置的值(我在 10 年前尝试过)并不重要,当我访问并重新加载我的应用程序(总是清除浏览器最近的历史记录)时,第一次访问时我会得到状态 200 ,304 为铰孔。
有什么方法可以得到谷歌文档中描述的行为吗?我的意思是,浏览器不会尝试从我的网站获取静态资源?
Well, I'm trying to optimize my application and currently using page speed for this. One of the strongest recommendations was that I needed to leverage browser caching. The report sent me to this page:
http://code.google.com/intl/pt-BR/speed/page-speed/docs/caching.html#LeverageBrowserCaching
In this page there is this quote:
If the Last-Modified date is
sufficiently far enough in the past,
chances are the browser won't refetch
it.
My point is: it doesn't matter the value I set to the Last-Modified header (I tried 10 years past), when I access and reload my application (always clearing the browser recent history) I get status 200 for the first access, and 304 for the reaming ones.
Is there any way I can get the behavior described in the google documentation? I mean, the browser don't try to fetch the static resources from my site?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Expires 标头(也列在该 Google 文档链接上)可能会取得更好的成功。
另请记住,所有这些与缓存相关的标头都是浏览器需要遵循的提示或建议。不同的浏览器可能有不同的行为。
测试方法就是一个很好的例子。在您的例子中,您提到为剩余请求获取状态 304,但是您是通过手动浏览器刷新来获取这些状态的吗?在这种情况下,浏览器通常会发出请求。
You might have better success using the Expires header (also listed on that Google doc link).
Also keep in mind that all of these caching-related headers are hints or suggestions for browsers to follow. Different browsers can behave differently.
The method of testing is a good example. In you case you mentioned getting status 304 for remaining requests, but are you getting those by doing a manual browser refresh? Browsers will usually do a request in that case.