首页 > 解决方案 > Why is Lighthouse failing my cached files?

问题描述

I'm using Google Lighthouse to calculate a performance score. One of the criteria is caching static assets such as images and scripts.

I don't have control over all of these, but the ones I do have control over the cache has been set to 30 days. However, Lighthouse is still reporting these as an issue. Lighthouse does report these as having a 30d cache, but still reports as an issue.

What do I need to do to rectify this?

Please see screenshot below:

Lighthouse Static Assets

标签: apachehttpcachingauditlighthouse

解决方案


我还有一个 30 天的缓存策略,为我解决这个问题的方法是将 public 和 no-cache 值添加到 Cache-Control 标头。

我只是在测试 Firebase 托管与我的旧主机(即 IIS)时才发现这一点。IIS 托管站点正在通过,即使它的 max-age 值更短。我检查了 chrome 中的网络开发人员工具,发现它在我的 IIS web.config 中的 Cache-Control 标头下有公共和没有缓存值,但我的 firebase.json 没有这些值。一旦添加,我再次通过!

现在为什么这对我来说是一个谜,但看看你是否可以再次添加和测试。


推荐阅读