如何解决pagespeed上的“利用浏览器缓存显示”?

时间:2017-05-31 15:41:08

标签: caching pagespeed google-pagespeed

我在一个网站上获得了99/100的分数,但是有关于杠杆浏览器缓存的持续消息不允许我获得100/100。

有人知道如何解决它?

enter image description here

1 个答案:

答案 0 :(得分:1)

以下代码告诉浏览器要缓存的内容以及记住它的时间。它应该添加到.htaccess文件的顶部

<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 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"
</IfModule>