Google PageSpeed - 设置到期日期

时间:2012-10-23 21:36:19

标签: performance apache caching memcached centos

我使用的是CentOS 5 32位,我刚刚在Google上扫描了我的网站以获得网页速度,它给了我以下内容:

“在静态资源的HTTP标头中设置过期日期或最长期限,指示浏览器从本地磁盘而不是通过网络加载以前下载的资源。”

有人可以告诉我如何在我的Apache服务器中启用它?

1 个答案:

答案 0 :(得分:2)

首先确保已加载mod_expires然后,您可以在httpd.conf文件中或在VirtualHost内定义:

   <IfModule mod_expires.c>
   FileETag MTime Size
   ExpiresActive on

   ExpiresByType application/javascript "access plus 1 week"
   ExpiresByType application/x-javascript "access plus 1 week"
   ExpiresByType application/x-shockwave-flash "access plus 1 week"

   ExpiresByType text/css "access plus 1 week"

   ExpiresByType image/jpg "access plus 1 month"
   ExpiresByType image/jpeg "access plus 1 month"
   ExpiresByType image/gif "access plus 1 month"
   ExpiresByType image/png "access plus 1 month"
   ExpiresByType image/x-icon "access plus 6 month"
   ExpiresByType image/ico "access plus 6 month"

   </IfModule>

希望这有帮助!