【问题标题】:Google PageSpeed - Setting an expiry dateGoogle PageSpeed - 设置到期日期
【发布时间】:2012-10-23 21:36:18
【问题描述】:

我使用的是 CentOS 5 32 位,我刚刚在 Google 上扫描了我的网站以了解页面速度,它给了我以下信息:

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

有人可以告诉我如何在我的 Apache 服务器中启用此功能吗?

【问题讨论】:

    标签: performance apache caching memcached centos


    【解决方案1】:

    首先确保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>
    

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2011-02-10
      • 1970-01-01
      • 2011-04-23
      • 1970-01-01
      • 2010-11-16
      • 1970-01-01
      • 2016-07-04
      • 2011-11-04
      相关资源
      最近更新 更多