Is there a reason the "Percent cached" rate is so low with Cloudflare Pages (even with custom headers)?


The vast majority of all traffic to my primary domain (>90%) currently comes from a Cloudflare Pages site set up on it (custom subdomain). I noticed that this tanked that domain’s cache hit percentage, but I saw that the cache-control header was “public, max-age=0, must-revalidate” and assumed that I could just update that to fix the issue.

I set custom headers and first thing I tried was public, max-age=86400, but this had no effect. I changed it to public, s-maxage=604800 and still no effect. My domain’s cache hit percentage is in the single digits with the exception of whenever some Hong Kong IP address sends me like a billion requests at once. I verified that these header changes did take effect and waiting 24 hours each time.

Any idea why Cloudflare Pages can apparently almost never hit cache?

Cloudflare Pages doesn’t need the typical CDN cache since it uses KV - so they are cached by KV when requested at a PoP.

tl;dr don’t worry about it, it’s cached using Workers.

Thank you.

Should I set it back to what it was originally? (public, max-age=0, must-revalidate)

The Cache-Control will also dictate if it’s cached in user’s browsers - so amend it based on if you want that or not.

1 Like

A way to to do this is a page rule to cache e.g your jpegs.

  1. Create a rule:
    URL: domain//images/.jpg (should match all jpegs on all subdomains)
    Cache level: cache evertying
    Browser cache TTL: 7 days (change to suit your needs)
    Edge cache TTL: 7 days (change to suit your needs)

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