【问题标题】:PageSpeed insight results are not being updated even after modifying the files即使修改文件后,PageSpeed 洞察结果也不会更新
【发布时间】:2016-11-07 16:48:08
【问题描述】:

我的 .htaccess 文件中有以下代码:

<IfModule mod_expires.c>
ExpiresActive On

ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
</IfModule>

这意味着jpgjpeg 图像的缓存到期日期应为 1 年。 Chrome 的 DevTools 控制台中的响应标头反映了这一点。

content-type:image/jpeg
date:Mon, 07 Nov 2016 04:05:46 GMT
expires:Tue, 07 Nov 2017 04:05:46 GMT
last-modified:Sun, 06 Nov 2016 18:40:41 GMT

但是,在 PageSpeed 洞察力中,建议显示缓存仅在 5 小时内有效,我应该增加该时间。这是为什么呢?

【问题讨论】:

    标签: .htaccess caching http-headers pagespeed google-pagespeed


    【解决方案1】:

    您应该使用较新的Cache-Control 标头:

    Cache-Control: max-age=<some-time-in-seconds>, public
    

    旧的 HTTP/1 Expires 标头不精确,在涉及中间缓存时会导致问题。

    Google PageSpeed 可能假定浏览器不会尊重它。在这种情况下,浏览器将恢复到所谓的启发式缓存,其中到期通常计算为Last-Modified 日期与现在之间差异的一小部分(例如 20%) - 这将产生类似的值到你看到的那个。

    【讨论】:

      猜你喜欢
      • 2013-03-03
      • 1970-01-01
      • 2021-07-26
      • 1970-01-01
      • 1970-01-01
      • 2012-12-01
      • 1970-01-01
      • 2019-04-22
      • 2022-11-04
      相关资源
      最近更新 更多