【发布时间】:2017-03-30 16:54:36
【问题描述】:
我正在使用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
提前谢谢你!
【问题讨论】:
-
你能给我们看看至少扫描的输出还是给我们网站什么的?
-
你可能甚至没有加载 mod_expires 模块?
标签: php .htaccess caching browser-cache