Is it possible to use a request header as a cache key?


#1

Hi,

I’m trying to create a page rule for caching a non-static resource. But the request for this resource has an header that can vary. This header is custom; it has nothing to do with the usual HTTP cache headers.

I want the cache to have into account that header. Like if the header was part of the cache key. Is it possible to be done? I’m not being able to accomplish that.

I’m my page rule I’m using “Cache Level” setting with value “Cache Everything”. Shouldn’t this setting be sufficient for the cache to be sensitive to different values of custom headers?

Best Regards,
Diogo Rocha


#2

Unfortunately you can’t do that.

I am assuming you want a solution that sends out a different version for every possible value of that custom request header.

I am curious as of what the use case for something like that would be?

You may be able to work out something “clever” with service workers depending on what you are trying to achieve.


#3

Might be related to the recent whitepaper/talk on cache poisoning: https://youtu.be/j2RrmNxJZ5c

See how Cloudflare is mitigating the issue:


#4

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