Removing Origin header from cachekey

The default cachekey is as follows according to Creating Cache Keys – Cloudflare Help Center

  "query_string": {
   "include": "*",
   "exclude": []
  "header": {
    "include": ["origin"],
    "exclude": [],
    "check_presence": []
  "host": {
    "resolved": false
  "cookie": {
    "include": [],
    "check_presence": []
  "user": {
    "device_type": false,
    "geo": false,
    "lang": false

However, changing the cachekey is an enterprise only issue. Is there any way to just remove the Origin header from the cache key?

Would contacting support be of any help?

In you are not on an enterprise plan you can run a worker which removes the Origin request header from the request before doing a fetch to the cache.

I see, but that’s going to be quite expensive then since every request would be charged for

There will be a cost yes, but depending on your use case and volume it might not be that expensive. You would only need to run the worker on URLs that are likely to receive Origin request headers, reducing the cost exposure.

I presume the reason you want to eliminate the Origin header from the cache key is that you already issue a Access-Control-Allow-Origin: * response header, and you want to reduce the volume of traffic to your origin server. In which case it is a trade off between the cost of the worker, and the cost of serving this content from your origin. I would have preferred that the Origin cache key was presented as an option in Page Rules, but that will probably never happen as workers can meet that requirement.

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