Workers + Image Resizing + Tiered Cache + Cache Reserve

For Workers & Pages, what is the name of the domain?

n/a

What is the issue or error you’re encountering

Is my Worker logic eligible for Cloudflare’s advanced caching?

What are the steps to reproduce the issue?

I’ve implemented a Cloudflare Worker that performs image resizing under the hood, utilizing caching through the fetch() method as follows:

let response = await fetch(signedRequest, {
cf: {
image: imageOptions,
cacheTtl: 86400,
cacheEverything: true,
}
});
This worker serves a set of predefined image transformation presets that change infrequently.

I’d like to clarify whether enabling Tiered Cache and Cache Reserve can improve the cache hit rate for my worker’s logic. The documentation states that image transformations are not eligible for caching with Tiered Cache and Cache Reserve, but what about the responses generated by my Worker?

Specifically:

  • Will Tiered Cache and Cache Reserve work at all if I enable them for the domain my Worker operates on?
  • If so, would they provide any caching benefits for the responses returned by my Worker?

Workers run in front of cache. No matter what response headers or what cache rules you setup, your worker responses will never be cached like normal origin responses. You can use the Cache API within your Worker, but that’s just local cache, and not tiered or cache reserve.

I see the bit in the documentation about Cache Reserve not working with Images, but Image Resizing does use Tiered Cache as far as I know.
Not sure if it’s in the docs anywhere, but it was said by an employee in the Developers Discord a while ago:
image
Since the new billing model is per unique resizes per month, and Cache Reserve can slow things down, probably makes sense not to have it anyway. Cache Reserve can still cache your origin image, just not the resized

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.