Cache worker response

Can you get Cloudflare to cache the response of a worker as if it was static? Imagine a simple worker that retrieves a static file from a private location and doesn’t do anything else - even with the cache api, it makes zero sense to run this worker for every single request and thus incur per-request cost.

Here’s a recent discussion on the topic:

I see. That’s very unfortunate. Any idea when such a thing might be supported? There are many people trying to use workers just to retrieve files from a origin that does not support custom domains ( such as ) and this would make it a lot more realistic to do so.

That sounds like two different requirements:

  1. Have a cache in front of the worker. (CF Cache is behind the worker)
  2. Use workers to pull content from a third party (this part is possible…see below)

A Cloudflare engineer has a Worker script that pulls Google fonts and delivers them through your domain, and can be cached (if I recall correctly):

Yeah. Retrieving the files with the worker is easily done (the page from Backblaze actually has an example too) but then it’s not possible to cache the result as if it were a normal file retrieved from the origin - causing unnecessary overhead for Cloudflare to run the worker, and unnecessary per-request cost for the user.

So it would be extremely useful if you had an option to cache not the sub-requests done by the worker, but the entire response. Maybe it could be controlled by cache headers like normal - if you set a cache header on the response in the worker it’d cache it as expected and not run it again for that query.