我使用https://developers.google.com/speed/pagespeed/insights/并且它显示我的网站上的每个图片都没有被缓存。我尝试过使用W3 Total Cache,编辑.htaccess:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
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 text/html "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 1 month"
</IfModule>
## EXPIRES CACHING ##
而且:
<filesMatch ".(ico|pdf|flv|jpg|svg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=84600, public"
</filesMatch>
代码,但无济于事。 为什么图像没有被缓存?有办法解决这个问题吗?
PageSpeed的链接:https://developers.google.com/speed/pagespeed/insights/?url=darbas.pcz.lt
提前谢谢!
答案 0 :(得分:1)
您需要添加单词plus
才能使其正常工作,
否则你说expires when its accessed one month
。没有意义。
ExpiresActive On
ExpiresDefault "access plus 14 days"
ExpiresByType application/javascript "access plus 30 days"
ExpiresByType text/css "access plus 30 days"
ExpiresByType application/x-httpd-php "access plus 30 seconds"