We use Pages and Functions. How can we provide up-to-date information without it being cached by CDNs or browsers?
We do not want to cache html because we are dealing with information that is updated from time to time, such as weather forecasts. But our information is cached, so the weather forecast from a few days ago is still displayed.
We have isolated the cause. Functions are correctly updated. We can access the Function API with a browser or curl to get the latest information.
We tried to retrieve it with cache disabled as follows.
curl -H ‘Cache-Control: no-cache, no-store’ -v ‘https://XXX.XXX/XXX/XXX’
However, the header returned only old information, including maxage, etc., as follows
However, only old information was returned, including max-age=604800 in the header.
We have tried Purge Cache’s Purge Everything. But the information is still out of date. We have also cleared the browser cache. But the information is still out of date. How can we always get new information?
Cloudflare Pages is already ‘cached’ on the edge so it doesn’t need (or use) the typical cache that you’re referring to - if you hit one of the pages you’re having an issue with using curl -sSI https://domain.com, what’s the CF-Cache-Status header that you get back?
I’d recommend removing any Page Rules or headers that you’re setting specify & making a new deployment - as far as I’m aware, the default caching policy on Pages will automatically handle purges and determining if a 200 OK or 304 Not Modified response is returned on it’s own.
When there’s no Page Rules or any other headers that you’ve added with the intent of changing the caching behaviour, new deployments should remove old versions of the assets on their own (with the Purge Everything button being a fallback to that).
We had already removed the Rule, but took your advice and set the Browser Cache TTL back to the default value of 4 hours. In addition, we implemented Purge Everything in the Purge Cache.
To us there appears to be no change in that.
Talk to whoever mange’s the intermediary systems and the origin. Cloudflare is pulling ‘Dynamic’ content from whatever is specified as the origin according to the cf-cache-status header. If it is stale it is downstream and outside of Cloudflare’s control.
We are confused because we have gotten multiple advices.
If we don’t have any Rule settings or cache settings, are they not cached?
We have 3 projects running on Cloudflare Pages and one of them appears to be not cached with no settings. However, the other two projects appear to be cached with the same settings. We do not know the difference.