利用浏览器缓存不起作用
Leveraging Browser Caching Not Working
我知道我的 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 ##
谢谢!
您必须启用 mod_expires。键入此命令并重新启动 apache 服务器:
sudo a2enmod expires
Enabling module expires.
Run '/etc/init.d/apache2 restart' to activate new configuration!
我知道我的 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 ##
谢谢!
您必须启用 mod_expires。键入此命令并重新启动 apache 服务器:
sudo a2enmod expires
Enabling module expires.
Run '/etc/init.d/apache2 restart' to activate new configuration!