我已将Expire Headers添加到我的.htaccess:
## EXPIRES CACHING ##
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
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"
## EXPIRES CACHING ##
但是gtmetrix说“有30个静态组件没有远期到期日期。”
我意识到所有带有查询字符串的文件都不包括在内。例如:
history.js?ver=1.7.1
history.adapter.jquery.js?ver=1.7.1
jquery.form.min.js?ver=3.48.0-2013.12.28
respond.min.js?ver=3.8.1
如何为这些文件添加缓存?
感谢。
答案 0 :(得分:0)
afaik mod_expire
忽略查询字符串但是,您可能需要包含更多类型,例如
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
通配符也可以帮助你
ExpiresByType image/* "access plus 1 year"