简体   繁体   English

利用浏览器缓存(PageSpeed Insights)

[英]Leverage browser caching (PageSpeed Insights)

I'm trying to pass Google Adsense warnings about what I should fix. 我正在尝试通过Google Adsense警告有关应解决的问题。 This caching stuff makes my butt hurt. 这些缓存内容使我的屁股受伤。 Running Debian 7 with Wordpress 3.7.1. 在Wordpress 3.7.1上运行Debian 7。 May be that Adsense just not love me? 可能是Adsense不爱我吗?

Tried all I found on Google and sure on here. 尝试了所有我在Google上发现的内容,并确保在此处找到。 Like: 喜欢:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 86400 seconds"
ExpiresByType application/x-javascript "access plus 86400 seconds"
</IfModule>

And similar: 和类似的:

<IfModule mod_expires.c>
 ExpiresActive on
 ExpiresDefault "access plus 1 month"
 ExpiresByType application/javascript "access plus 1 year"
 ExpiresByType image/x-ico "access plus 1 year"
 ExpiresByType image/jpg "access plus 14 days"
 ExpiresByType image/jpeg "access plus 14 days"
 ExpiresByType image/gif "access plus 14 days"
 ExpiresByType image/png "access plus 14 days"
 ExpiresByType text/css "access plus 14 days"
</IfModule>

And even this, which crashes WP: 即使这样,也会使WP崩溃:

<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif|html|htm|xml|txt|xsl)$">
Header set Cache-Control "max-age=31536050"
</FilesMatch>

Tried to add these lines in .htaccess at WP root and just in case in themes directory too. 试图将这些行添加到WP根目录的.htaccess中,以防万一在主题目录中。 Tried some WP plugins with no luck. 尝试了一些没有运气的WP插件。

Found solution: 找到的解决方案:

on debian based distro's it is as easy to do as typing then a2enmod headers and a2enmod expire 在基于debian的发行版上,就像键入然后a2enmod标头和a2enmod过期一样容易

Source: http://forum.slicehost.com/index.php?p=/discussion/3400/install-apache-modules/p1 来源: http : //forum.slicehost.com/index.php?p=/discussion/3400/install-apache-modules/p1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM