Subrequests + caching


I’m trying to use a Worker to forward requests to another Cloudflare zone (site). Here’s a simplification of our code:

if (shouldProxy(originalRequest)) {
  const proxyURL = new URL(originalRequest.url)
  proxyURL.hostname = ''
  const proxyRequest = new Request(proxyURL, request)
  return fetch(proxyRequest, { cf: { cacheKey: originalRequest.url, cacheEverything: true } })

I want to enable caching on the parent zone, but not on the sub-zone so I don’t need to issue purge requests on both zones.

What I Expect

  1. client makes request to Cloudflare
  2. Worker changes URL, calls fetch using original URL as the cache key
  3. fetch checks cache on the primary zone
  4. on a cache-miss, fetch forwards the request to the sub-zone
  5. sub-zone processes via Firewall, Page Rules, Workers, etc.
  6. on a cache-miss in the sub-zone, Cloudflare forwards the request to origin

What is Happening

These requests seem to be bypassing the main zone’s cache. All forwarded responses are coming back as DYNAMIC.


The Worker docs say

A request’s cache key is what determines if two requests are the same for caching purposes. If a request has the same cache key as some previous request, then Cloudflare can serve the same cached response for both.

The examples section also says

Respond to the Worker request with the response from another website ( in this example).

But they don’t specify which site’s cache settings are used if the “other website” is another Cloudflare site in the same account.

The Understanding Subdomain Support docs don’t mention caching or workers at all. It does say

The parent domain loses configuration control over the subdomain once the child subdomain is added to Cloudflare. For instance, ’s Page Rule for will no longer work when the child subdomain is added to Cloudflare. Move Page Rule configuration from the parent domain to the child subdomain before activating the child subdomain with TXT records or setting NS records .… This concept applies to any Cloudflare feature configured for the child subdomain such as Rate Limiting, DNS, and Firewall Rules .

That implies that Caching and Purging are also delegated, but doesn’t say anything explicitly. It also doesn’t say whether that rule applies to requests that go through both the parent and the child.