简体   繁体   English

利用浏览器缓存不起作用

[英]Leverage browser caching not working

im building a new site and i'm trying to improve its speed and page rank. 即时通讯正在建立一个新网站,我正努力提高其速度和网页排名。 One of the problems i have is Leverage browser caching. 我遇到的问题之一是利用浏览器缓存。 I've read online different solutions, but none of them seems to work for me. 我在网上阅读了不同的解决方案,但似乎没有一个适合我。 I edited the .htaccess file and added the following code: 我编辑了.htaccess文件,并添加了以下代码:

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
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 text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

I still cannot fix the error. 我仍然无法修复该错误。 Also, Gtmetrix report shows that the problem is only with my front page images. 另外,Gtmetrix报告显示问题仅出在我的首页图像上。 (I'm using wordpress and front page is a static page). (我使用的是wordpress,首页是静态页面)。 Is there a way to add expiry header to specific files by location ? 有没有一种方法可以通过位置将过期标头添加到特定文件? Thanks in advance :) 提前致谢 :)

That codes works only in apache service. 该代码仅在apache服务中起作用。 please inter your website address. 请输入您的网站地址。 for more information: https://gtmetrix.com/leverage-browser-caching.html https://developers.google.com/speed/docs/insights/LeverageBrowserCaching 有关更多信息: https : //gtmetrix.com/leverage-browser-caching.html https://developers.google.com/speed/docs/insights/LeverageBrowserCaching

I have just resolved it. 我刚刚解决了。 You have to enable mod_expires module. 您必须启用mod_expires模块。 Have a look on my answer :- Leverage browser caching not working - Htaccess & mod_expires Active 看一下我的答案:- 利用浏览器缓存不起作用-Htaccess和mod_expires有效

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

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