我在htaccess中使用以下代码来利用浏览器缓存,它设置了1个月的到期时间 javascript,但当我测试这个谷歌页面速度洞察它要求增加各种js到期,它显示设置为默认为什么它发生2天?
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 7 days"
ExpiresByType image/jpeg "access 7 days"
ExpiresByType image/gif "access 7 days"
ExpiresByType image/png "access 7 days"
ExpiresByType text/css "access 7 days"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
答案 0 :(得分:9)
尝试设置:
ExpiresActive On
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/json "access 1 month" // Thanks to David Goss
另请参阅:http://www.quickonlinetips.com/archives/2010/05/leverage-browser-caching-increase-website-speed/
答案 1 :(得分:0)
尝试:
ExpiresActive On
ExpiresByType text / javascript“access plus 1 years”
ExpiresByType application / x-javascript“access plus 1 years”
ExpiresByType应用程序/ javascript“访问加1年”
链接:
http://httpd.apache.org/docs/current/mod/mod_expires.html
http://www.inmotionhosting.com/support/website/htaccess/apache-module-mod-expires