I have been trying to get a HTML response (without authentication or cookie) to be cached by Cloudflare, even for a short time.
Each time I get ‘dynamic’ back, not ‘hit’. So that indicates Cloudflare has not cached it.
Reading the docs, it seems by default HTML responses are not cached, even without authentication, and you have to instruct Cloudflare to do that.
So I tried adding the
Cloudflare-CDN-Cache-Control header to the response to instruct Cloudflare to cache the page for X seconds. Yet … it doesn’t. It seems. I read the docs (https://developers.cloudflare.com/cache/about/cdn-cache-control) as meaning that if
*-CDN-cache-control headers are not present, it would fall back to defaults. So, not caching HTML. Which makes sense. But if they are present … indeed with a
Cloudflare- prefix making clear the intention … it seems that still HTML responses are still not cached.
Do you have to also add a Page Rule? I assume it is the one to enable Origin Cache Control? I can’t see an option for that in the Caching tab, or elsewhere.
If so it would be nice if
Cloudflare-CDN-Cache-Control was seen by the proxy and respected for a response. As it can see the headers at the same time it is checking the file extension in the path to decide if it should cache or not. Perhaps there is a technical reason why it can’t.