【问题标题】:Leveraging Browser Caching Not Working利用浏览器缓存不起作用
【发布时间】:2016-09-18 04:52:42
【问题描述】:

我知道我的 htaccess 文件正在被 Google Pagespeed 正确读取(它正确读取我已启用压缩,当我删除该文件时它说我没有启用压缩),但它无法读取我已启用浏览器缓存。我的 htaccess 文件中有以下代码。为什么它不起作用?

## 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 ##

谢谢!

【问题讨论】:

  • 尝试添加这个:"access plus 1 year" 而不仅仅是"access 1 year"

标签: .htaccess caching browser-cache pagespeed


【解决方案1】:

您必须启用启用 mod_expires。键入此命令并重新启动 apache 服务器:

sudo a2enmod expires
Enabling module expires.
Run '/etc/init.d/apache2 restart' to activate new configuration!

【讨论】:

    猜你喜欢
    • 2016-08-13
    • 2018-03-27
    • 2018-06-16
    • 2017-01-20
    • 2014-12-24
    • 2013-01-21
    • 2011-10-15
    相关资源
    最近更新 更多