Cache rule not creating expected caching behaviour
Hey all,
I am having some confusing issues with caching requests that I am routing through a worker.
The setup I have is a Cloudflare worker at a custom domain - "something.com" - and a CNAME DNS record in the same zone which points the "origin.something.com" subdomain towards my AWS cluster. The worker handles the request and forwards it to "origin.something.com" by modifying the url of the request.
In my caching rules I have cache everything rule set on for requests matching "(http.request.full_uri contains "origin.something.com")", and a separate bypass cache rule for good measure with "(http.host eq "something.com")"
Therefore, my understanding would be that requests to something.com, hit cloudflare, bypass the cache, reach the worker, are forwarded to "origin.something.com", then hit the cache or sometimes miss and go to my AWS cluster.
However, currently all of my cache hits in the Caching overview show as having "something.com" as their host. Can anyway see what is going wrong here?
1 Reply
Can anyway see what is going wrong here?Well I would start with asking the question, What do you think is right here? That your requests are being cached right? Check the CF-Cache-Status header on the response, easiest way to determine if the response is cached or not
Therefore, my understanding would be that requests to something.com, hit cloudflare, bypass the cache, reach the workerWorkers always run in front of cache you have nothing to worry about there.
However, currently all of my cache hits in the Caching overview show as having "something.com" as their hostThe caching overview filters requests to only show ones made by eyeballs/actual users. There is request sources of "edgeWorkerFetch" which it is purposefully excluding. You see the cache analytics from your worker endpoint most likely just because it's returning the Cf-Cache-Status header and CF is using that (not confirmed but pretty likely). I would check first if there's an actual issue/something isn't being cached where it should be, and then the rest is just fun analytics stuff