I would like to know the total cache size for both the free and pro offers. My question is about the total cache of a site, not of a single file. If we configure with max-age, is a file not removed from the cache before its expiration? Even if the file has few visits?
There is none. There is only per file size limits:
Free, Pro and Business customers have a limit of 512 MB.
For Enterprise customers the default maximum cacheable file size is 5 GB. Contact your account team to request a limit increase.
Cloudflare will indeed evict files from cache based on relative frequency of access (i.e unpopular assets will be evicted). Cache is also by default per cloudflare location, although tiered caching and cache reserve add extra layers on top of that.
max-age is a “do not cache for longer then”, not a “cache for this long”. There is no guarantees for how long something may be in cache.
Cloudflare will indeed evict files from cache based on relative frequency of access
In order to organize myself, do you have an idea of the frequency of eviction ? I mean is it like “if a file is not access after 2 days” of if it is 2 weeks.
I don’t believe the docs detail it fully, but my understanding is its based on a lot of factors like file size, how much cache room they have in that location, and overall relative frequency of file use, etc. It’s kind of hard to guess, because it’s per cloudflare colo (specific datacenter, kind of), and some cloudflare locations/points of presence even have multiple colos. If you have 1,000 requests spread equally world-wide, you’d see much less cache % then all hitting a single colo in a single location.
If the file wasn’t accessed at all other then the first hit, I wouldn’t expect it to survive more then an hour or two, regardless of max-age
There’s a few blog posts that lightly touch on it, fun reads:
If you want higher cache %, consider Tiered Caching. The default version is free and available to anyone, Cloudflare automagically picks a location closest to your origin to be a secondary “fallback” like cache before contacting origin (Edge Cache → Tiered Cache Location → Origin). If cache is critical, consider Cache Reserve. It is paid, and a feature built on top of R2, Cloudflare’s Object storage. It’s a sort of “perma-cache” with a guarantee of how long something it will be cached: Introducing Cache Reserve: massively extending Cloudflare’s cache