Cloudflare cache serving outdated page
Hello,
I've been running my site on cloudflare pages for a few months now, and recently I have started noticing an odd issue.
The cloudflare cache appears to sometimes cache the pages HTML file, and does not update when a new deploy happens.
Specifically, it caches the html page. The I deploy a new version of the site and the path to the stylesheet changes. Cloudflare still serves the old html with the link to the old stylesheet, but it does not exist anymore, leading to the page having messed up styles.
For now I've added a cache rule on the site to exclude the apex from caching. Is there a better way to do this?
8 Replies
Hi @ajgeiss0702, I’ve passed this internally to see if the team knows a better way to do it
Thank you ❤️
Users should avoid setting up any custom caching rules on custom domains if they're using Pages. We already cache assets in an optimal way, so any second layer just has the propensity to serve stale content. We have a couple of notes on this: https://developers.cloudflare.com/pages/platform/debugging-pages/#differences-between-pagesdev-and-custom-domains https://developers.cloudflare.com/pages/platform/custom-domains/
The only cache rule I have is to exclude the apex (which points to the pages project)
Before adding this rule, I had no cache rules.
I don’t think I can switch it to dns-only mode due to it being on the domain apex (unless im misunderstanding how cname flattening works)
Does the rule work for you now? Are you continuing to serve stale content?
it appears to be working now, yes. I'm just wondering if there is a better way as this almost feels hacky
Not really, there's a long-standing desire to simplify how we do caching (or at least provide some more control over and documentation around the existing system) but no movement or ETA on that yet
alright, thanks for the info. i guess ill try to keep my eye on that