我从谷歌速度测试中得到了这个错误:
以下可缓存资源的新鲜度生命周期较短。为以下资源指定至少一周后的到期时间:
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文件中做些什么吗?
发布于 2011-07-24 03:01:57
看起来静态文件没有设置expires。Read - http://www.absolutelytech.com/2010/08/02/howto-add-expire-headers-to-cache-static-files-using-htaccess/
您需要在.htaccess中发布以下代码
# Turn on the Expires engine
ExpiresActive On
# Expires after a month client accesses the file
ExpiresByType image/jpeg A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/plain A2592000
# Good for one week
ExpiresByType application/x-javascript M604800
ExpiresByType text/css M604800
ExpiresByType text/html M604800发布于 2015-12-14 12:02:06
PageSpeed:利用浏览器缓存每次浏览器加载网页时,它必须下载所有web文件才能正确显示页面。这包括所有的HTML,CSS,javascript和图片。
要启用浏览器缓存,您需要编辑HTTP标头,以设置某些类型文件的过期日期。
在你的域的根目录中找到你的.htaccess文件,这个文件是一个隐藏的文件,但应该在FileZilla或CORE这样的FTP客户端中显示出来。您可以使用记事本或任何形式的基本文本编辑器编辑htaccess文件。
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
https://stackoverflow.com/questions/6794033
复制相似问题