Cache Purge

I'm trying to use CF Pages, but I can't find a way to purge cache (after CMS changes), not even after deployment. All I can find to purge cache is related to zones, but I don't even have that option. How to do this?
14 Replies
Hello, I’m Allie!
If you aren’t manually caching with a custom domain, then Pages should auto-clear its cache within about a minute
peterz
peterzOP2y ago
I'm not, I don't have a custom domain (yet). I was expecting that too, but it isn't... May it be related to the fact that I'm sending cache headers on the responses?
Hello, I’m Allie!
That’s probably it. Pages is pretty good at handling its own cache, so you don’t need to do it yourself
peterz
peterzOP2y ago
But when I wasn't sending those headers, it wasn't caching at all 😕
Hello, I’m Allie!
IIRC, you can't actually see if the Response was cached(on Pages), since it uses the KV cache system, rather than the regular Cache API.
peterz
peterzOP2y ago
hmm... does it mean CF doesn't return the cf-cache-status: HIT and Cache-Control: ... headers in that case, but still responds with a cached version? Then the browser doesn't cache anything too...
Hello, I’m Allie!
IIRC, it sends a Cache-Control that allows the content to be cached in the browser, but it needs to be revalidated on every request
peterz
peterzOP2y ago
ok, thanks. I'm gonna make a few more tests 👍 If I don't send the cache headers, CF doesn't cache at all. How can I purge cache?
Hello, I’m Allie!
The KV cache?
peterz
peterzOP2y ago
I guess yes... if it's caching there when I send the cache headers But I don't have any of that configured. I just created a Pages app. If my app responds with cache headers, CF caches it and responds with cache version (I can see both the cache status HIT and if I change content on the CMS the response doesn't change). If my app doesn't respond with cache headers, CF doesn't cache at all (I can confirm it by making changes on the CMS).
Hello, I’m Allie!
That's what I was talking about above. When working correctly, Pages shouldn't show a Cache Hit, since the system that handles caching for Pages doesn't add the Cache-Status Headers.
peterz
peterzOP2y ago
Ok. So, for this scenario, I want to cache my responses, but I also want to be able to purge the cache at any time. I've seen that re-deploying doesn't purge the cache. How can I do this?
Hello, I’m Allie!
Using Cache Headers without a custom domain means you can’t purge the cache If it were on a custom domain, then you would be able to purge with the CF API But without a custom domain, you won’t be able to purge
peterz
peterzOP2y ago
Ok, got it, thanks a lot for clarifying 👌

Did you find this page helpful?