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
If you aren’t manually caching with a custom domain, then Pages should auto-clear its cache within about a minute
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?
That’s probably it. Pages is pretty good at handling its own cache, so you don’t need to do it yourself
But when I wasn't sending those headers, it wasn't caching at all 😕
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.
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...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
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?
The KV cache?
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).
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.
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?
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
Ok, got it, thanks a lot for clarifying 👌