【问题标题】:htaccess leverage browser caching for imageshtaccess 利用浏览器缓存图像
【发布时间】:2014-11-02 15:34:14
【问题描述】:

我在 .htaccess 文件中有这段代码

## EXPIRES CACHING ## 
<IfModule mod_expires.c>
    ExpiresActive On
# Media 
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/x-icon "access plus 1 year"
    ExpiresByType application/x-shockwave-flash "access plus 1 year"

# Codes
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType text/x-javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 year"

# Webfonts
   ExpiresByType application/x-font-ttf "access plus 1 year"
   ExpiresByType font/opentype "access plus 1 year"
   ExpiresByType application/x-font-woff "access plus 1 year"
   ExpiresByType image/svg+xml "access plus 1 year"
   ExpiresByType application/vnd.ms-fontobject "access plus 1 year"

   ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

但是当我尝试测试我的网站速度时,仍然出现“利用浏览器缓存”的错误!

当我尝试查看错误详情时:-

在使用上面的代码之前,我有很多链接! 现在我只有 png,jpg,js 文件。

希望你能帮助我。

【问题讨论】:

    标签: .htaccess caching browser-cache


    【解决方案1】:

    您需要启用 mod_expires。 用阿帕奇:

    a2enmod expires
    service apache2 restart
    

    【讨论】:

      猜你喜欢
      • 2012-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-15
      • 2011-11-12
      相关资源
      最近更新 更多