Lighthouse: Cache policy warning

Created on 21 Nov 2018  路  9Comments  路  Source: GoogleChrome/lighthouse

The performance check (PageSpeed test I鈥檓 looking at you) is reporting that 23 resources have an inefficient cache policy, but the detail actually shows that the cache policy is over 2 days, sometimes over 30 days

P2 docs web.dev

Most helpful comment

That's good to know. I don't think the guide that LH currently links to explains what the cache policy would need to be in order to pass the audit. If we're writing updated guidance on web.dev we can explain that.

All 9 comments

@erlapso can you share a URL we can test to verify?

Yeah this is also seems like a LH question since it shows up as a failure in DevTools as well. I wonder if the problem is that some of the resources don't have a cache policy, and so it's just showing you all of them.

@patrickhulce can you answer this one? I can't make sense of the uses-long-cache-ttl audit, it looks like we do some magic to show these results (calculate cache probability, ...) I see a lot of third party domains which you can't do much about. The ones that have TTL not sure why they show up

image

If it's anything less than ~6 months then it will show up here. Our recommendation is a year because if you're OK with having a 29 day old version is there really that much of a difference from a multi-month old version? If you cared about having it up-to-date you should probably be using must-revalidate :)

That's good to know. I don't think the guide that LH currently links to explains what the cache policy would need to be in order to pass the audit. If we're writing updated guidance on web.dev we can explain that.

If we're writing updated guidance on web.dev [...]

If you cared about having it up-to-date you should probably be using must-revalidate

must-revalidate is only taking effect after the resource has become stale (e.g. max-age has expired), instead use no-cache which: "_indicates that the response MUST NOT be used to satisfy a subsequent request without successful validation on the origin server._"

Thanks @Malvoz!

To clarify, I was referring to the fact that if you had something that really must be cached for 30 days but not any longer, you should be using must-revalidate. We use both no-cache and must-revalidate as signals for filtering. We won't flag assets with either directive.

@meggin fyi as we work on updating our audit docs :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timj2 picture timj2  路  3Comments

codepodu picture codepodu  路  3Comments

shellscape picture shellscape  路  3Comments

Simply007 picture Simply007  路  3Comments

radum picture radum  路  3Comments