Cf-cache-status: MISS for every new user

I want cache at CloudFlare static content like zip, doc, etc.
I’m create custom rule like that:

https://example.com/dist/*
Cache Level: Cache Everything

Configure static content on nginx

        location  ~* \.(jpeg|jpg|png|gif|zip) {
            expires 30d;
            add_header Cache-Control "public";
        }

Now I try get static content from my laptop

curl https://example.com/dist/file.zip -I
...
cf-cache-status: MISS
...

Try again

curl https://example.com/dist/file.zip -I
...
cf-cache-status: HIT
...

Great, working, but…
Try from another IP

curl https://example.com/dist/file.zip -I
...
cf-cache-status: MISS
...

Try again

curl https://example.com/dist/file.zip -I
...
cf-cache-status: HIT
...

What ?
How store static content once placed on cloudflare for everybody?

Cloudflare has many, many, caches on its edge nodes. The first visitor at any edge node location will get a MISS. The second visitor to that same node might get a hit. Each edge node has many servers, and they don’t all share the same cache.

In short, it takes a while for Cloudflare to cache data for everybody. That’s why super high-traffic sites have high cache rates: Lots of frequent hits from all over.

2 Likes

That’s what I don’t like about Cloudflare. When you have a website on Cloudflare PRO, with a global but low-volume audience, and your cache HIT ratio is extremely low. You might use <1% of the bandwidth of other CF websites (even on FREE), yet they get a much higher cache hit ratio. Just because my website has a low hit ratio, doesn’t mean I don’t want those few resources served as-fast-as-possible.

1 Like

I do wish Edge Cache TTL was biased a little (lot) more toward paid accounts, so paid accounts don’t have their static assets ejected from the cache so early. I don’t know what the algorithm is, but it’d be nice to get a hint as to what it is. Something along the lines of (how “full” your Edge Cache is) * (how often that resource is hit at that datacenter) * (plan multiplier: 1 for free, 2 for pro, 5 for business, 10 for enterprise) divided by some magic number.

1 Like

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