Cloudflare Images and cache eviction


I was wondering how exactly Cloudflare caches variants that have been served?

We have about ~800k images and 8 variants. We want to optimize our site for users (and google bots), so when we upload a new image, we “pre-load” the variants (by visiting their url), to ensure the first visitor will not have to wait for the initial conversion.

What we have noticed though, is that some/most of these images, after a while, will no longer seem to be in Cloudflare cache, so that a visitor will again have to wait for the initial conversion. When the image is already in Cloudflare cache user will wait up to 200ms, but when not in cache, user will wait for 800-1500ms (higher end especially if serving AVIF format).

My expectation was, that whenever a variant has been served in a specific format, that image will permanently be available for fast loading. But that does not seem to be the case.

Is this the behaviour we can expect?
How many images/variants/formats are stored in the cache?
What is the eviction policy from the cache?
Can we pay the increase the amount of images cached?


1 Like

My understanding is cloudflare charges per every request, cached or not. From a performance standpoint, you can get better request times from a cache hit, but pricing-wise, it’s a problem. Thumbnails are the biggest issue as a single user scrolling a feed or product listing can cause hundreds or more requests in a few seconds.

This is one reason I’m really looking forward to R2. $0.015 per GB and no egress fees. I’m hoping it’s somewhat fast when uncached, and will follow the same caching behavior as regular cached content.

1 Like

So R2 uploads are the only cost bandwidth-wise? Then probably a storage cost? That would be… amazing.

Is cloudflare images built on top of R2?

I don’t believe R2 was on the roadmap when images was released. In this blog post they explain how it’s built on top of CF workers.

I believe it’s storage cost only.

I think everything is somewhat interconnected. It’s all storage, whether it’s Cache, Durable Objects, Workers KV, Pages, Workers themselves, Stream, Images, and R2. It’s just a matter of how it’s all allocated and performance-tuned.

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