wordpress - 利用浏览器缓存不起作用

标签 wordpress .htaccess seo

我正在 build 一个新网站,我正在努力提高其速度和网页排名。我遇到的问题之一是利用浏览器缓存。我在网上阅读了不同的解决方案,但它们似乎都不适合我。我编辑了 .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 ##

我仍然无法修复错误。此外,Gtmetrix 报告显示问题仅出在我的首页图像上。 (我使用的是 wordpress,首页是静态页面)。 有没有办法按位置将过期 header 添加到特定文件? 提前致谢:)

最佳答案

该代码仅适用于 apache 服务。 请输入您的网站地址。 想要查询更多的信息: https://gtmetrix.com/leverage-browser-caching.html https://developers.google.com/speed/docs/insights/LeverageBrowserCaching

关于wordpress - 利用浏览器缓存不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39189898/

相关文章:

mysql - 如何从 Drupal 数据库中获取 post slug

php - 有没有人有一个很好的功能来删除 Wordpress 中的特定简码?

php - 5 .htaccess 重写 : Force HTTPS, 删除 index.php,删除 .php,强制 www,强制尾部斜线

html - 对蜘蛛程序隐藏页面内容的最佳方法是什么?

php - 存档产品的 `<ul>` 的 Woocommerce 位置

mysql - 空帖有用吗?

当数据库中缺少项目时,PHP 或 htaccess 使动态 url 页面转到 404

.htaccess - .htaccess 中的 header 设置 Access-Control-Allow-Origin 不起作用

jsf - 在 <welcome-file> 上使用重定向而不是转发

wordpress - SEO - 使用 href ="#"的下拉菜单