0

我有一个运行静态 html、css、js 站点的 centOS 灯服务器。谷歌的页面速度工具建议我“利用浏览器缓存”(因为这可能是我们想要实现它的谷歌 seo 排名因素)。这可以通过我网站的 .htaccess 文件来完成吗?

我在过去设置了这个,但只通过一个 wordpress 插件,所以它几乎是一键式的。

4

1 回答 1

2

Try to add this to the top of your htaccess-file:

## 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 ##
于 2016-05-15T20:52:57.610 回答