Cloudflare Cache / Cache Server

We have several websites here we have cache on. We see that for some websites the cache expires within a day, even if we have headers set to 1 month. Is the only solution Cache Reserve for this?

Cloudflare caches assets for at most the length cache TTL - it is not a guarantee. Assets can and will be evicted sooner if they do not get sufficient traffic. Small assets with lots of traffic on an Enterprise plan will stay in cache much longer than large assets with low traffic on the Free plan.

Enabling Cache Reserve does not increase the Edge Cache TTL and assets are still evicted if they do not get sufficient traffic. The difference being that when the asset is evicted, Cloudflare fetches it from an R2 bucket rather than your origin server. It can easily take around a second to fetch an asset from R2, so it is quite possible that fetching the asset from your origin server will be faster than fetching it from Cache Reserve.

Thanks for your response. Are there any solutions to ensure that even pages with few visits stay in the cache longer?

Not possible to guarantee, but upgrading the zone plan will make your assets be prioritised. But even on Enterprise, a small HTML page that doesn’t get requested for several hours is often evicted. And keep in mind that, unless your enable Tiered Cache, the cache is separate per colo. In general, enabling Tiered Cache is a good way to improve cache hit ratio.

We have now activated the Cache Reserve and the HIT ratio growth to almost 80%, so it seems to help?
Regarding the costs, can you maybe forecast the costs for it below?

From what I can tell, Cache Reserve is only helpful if your reason for caching is to reduce load on the origin server. If you are caching to improve the speed of your site, enabling Cache Reserve might actually make it worse.

Enabling Cache Reserve does not increase the time that assets are stored in the edge cache. What Cache Reserve does is fetch the asset from your origin and then store it in an R2 bucket. When the asset is purged from Cloudflare’s edge cache, Cache Reserve first checks if the object exists in the R2 bucket.

While this does reduce the number of request your origin needs to serve (thereby increasing cache hit ratio), fetching an object from R2 is pretty slow (it can take upwards of a second from my experience), so enabling Cache Reserve might actually slow down your site overall.

1 Like