When Cache Everything, HEAD requests will be turned into GET requests

I just did a separate experiment and proved this. And this is really a problem. Please look at my original post:

I know if a signature method is used, it won’t be anonymous pages, but I think this behavior should be documented, what if people return different things to GET and HEAD requests (although, it’s not a good practice). But this should be stated somewhere (Maybe it’s just me don’t find it).

It wouldn’t be correct to return different resources for a HEAD vs a GET - a HEAD request literally should get the same response except without the response body. When you make a HEAD request for a cacheable resource and Cloudflare does not have that resource in the edge cache, we make a GET to your origin and cache the full response and return just the headers to the client. This means subsequent HEAD or GET requests will be a cache HIT.

That said - the docs for caching are open source so you could submit a PR to include it or file an issue specifically to ask that this behaviour be explained:

2 Likes

Thank you so much for the explanation, for some third-party software as part of my backend, I really don’t have that much control, for example, minio, if you change HEAD to GET, the request signature won’t match anymore. Part of my static content is on it, but not all of them are static. If I just use Cache Everything, I’ll have the issue I mentioned here. But if I don’t use Cache Every Thing, my *.json, *.html file won’t be cached at all.

Is it possible to just let myself use Cache-Control to decide if something should be cached without turning HEAD to GET?

It’s not possible to influence that HEAD > GET behaviour so if you rely upon this non-standard behaviour then you would need to disable edge caching for the URLs which rely upon it.

Thank you!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.