Google Speed Leverage 浏览器缓存
我从 Google 速度测试中收到此错误:
以下可缓存资源的新鲜度寿命很短。为以下资源指定至少未来一周的到期时间:
http://localhost/english/favicon.ico (expiration not specified)
http://localhost/english/images/bg_center.png (expiration not specified)
http://localhost/english/images/bg_top.jpeg (expiration not specified)
http://localhost/english/images/footer_bg2.png (expiration not specified)
http://localhost/english/images/m_facebook.png (expiration not specified)
http://localhost/english/images/m_rss.png (expiration not specified)
http://localhost/english/images/top_bg.png (expiration not specified)
http://localhost/english/javascript/gram.js (expiration not specified)
http://localhost/english/javascript/top_start.js (expiration not specified)
http://localhost/english/jquery.js (expiration not specified)
http://localhost/english/style/gram.css (expiration not specified)
http://localhost/english/style/style.css (expiration not specified)
我应该在 htaccess 文件中执行某些操作吗?
I got this error from Google Speed test:
The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:
http://localhost/english/favicon.ico (expiration not specified)
http://localhost/english/images/bg_center.png (expiration not specified)
http://localhost/english/images/bg_top.jpeg (expiration not specified)
http://localhost/english/images/footer_bg2.png (expiration not specified)
http://localhost/english/images/m_facebook.png (expiration not specified)
http://localhost/english/images/m_rss.png (expiration not specified)
http://localhost/english/images/top_bg.png (expiration not specified)
http://localhost/english/javascript/gram.js (expiration not specified)
http://localhost/english/javascript/top_start.js (expiration not specified)
http://localhost/english/jquery.js (expiration not specified)
http://localhost/english/style/gram.css (expiration not specified)
http://localhost/english/style/style.css (expiration not specified)
Should I do somthing in my htaccess file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来静态文件没有设置过期时间。阅读 - http://www.absolutelytech.com/2010/08/02/howto-add-expire-headers-to-cache-static-files-using-htaccess/
您需要将以下代码发布到 .htaccess 中
Looks like the static files don't have expires set. Read - http://www.absolutelytech.com/2010/08/02/howto-add-expire-headers-to-cache-static-files-using-htaccess/
You'll need to post the below code in your .htaccess
PageSpeed:利用浏览器缓存
每次浏览器加载网页时,它都必须下载所有网络文件才能正确显示该页面。这包括所有 HTML、CSS、javascript 和图像。
要启用浏览器缓存,您需要编辑 HTTP 标头以设置某些类型文件的到期日期。
在域的根目录中找到 .htaccess 文件,该文件是隐藏文件,但应该显示在 FileZilla 或 CORE 等 FTP 客户端中。您可以使用记事本或任何形式的基本文本编辑器编辑 htaccess 文件。
PageSpeed: Leverage browser caching
Every time a browser loads a webpage it has to download all the web files to properly display the page. This includes all the HTML, CSS, javascript and images.
To enable browser caching you need to edit your HTTP headers to set expiry dates on certain types of files.
Find your .htaccess file in the root of your domain, this file is a hidden file but should show up in FTP clients like FileZilla or CORE. You can edit the htaccess file with notepad or any form of basic text editor.