Continuing the discussion from Cloudflare Workers Beta Feedback:
It’s unclear to me how Workers work in relation to Page Rules.
I ran into a situation today whereby a Page Rule was not applied to the request handled by a Worker.
The request matches this Page Rule:
-
https://example.com/*
: cache level: cache everything, browser cache: 1 hour, edge cache: 1 month.
With that rule Cloudflare responds for my HTML with:
cache-control: public, max-age=3600
But for the URL that I’m beta testing my worker on, no cache-control
header is added to the HTML response. Why is that?
My worker does perform a request to another domain, but if the browser visits https://example.com/my-page/
, shouldn’t the Page Rule for that URL kick in? But in my case the Worker actually disables the Page Rule.
I understand from the following quote that Workers cannot set cache-control
headers. That makes it more important for me that Page Rules do work, because otherwise there’s no caching happening with the Worker.