How do you do the equivalent of the page rule cache_level: "bypass" in a worker fetch?

When a client specifies the Range header in a request for a cacheable resource, Cloudflare fetches the entire resource and serves the specified range. This has several advantages:

  1. Cloudflare only makes a single request to the origin. When the client requests the next chunk, Cloudflare can simply serve it from cache.
  2. Since a 206 Partial Response is not cacheable, all requests with ranges would otherwise go to the origin, significantly increasing load.

I believe Cloudflare also transforms HEAD into GET requests for the same reason.

With that said, I can totally see how this is a disadvantage in your case. Unfortunately I don’t think there’s a way to bypass cache in a Worker. Instead you must ensure the resource is not cacheable. This leaves you with two options:

  1. Create a Page Rule with Cache Level: Bypass matching the affected URLs.
  2. Rename your resources to a non-cacheable extension.
1 Like