CloudFlare Cache -- Intermittent Hit and Miss

Dear Cloudflare Community,

My site is only intermittently hitting the Cloudflare Cache.
This is a static site and I want all the html document to be cached within Cloudflare for 24 hours (or until I manually purge them.

My configuration is as follows:

  1. Cloudflare is set to cache everything for one day:

  2. There are no other settings in Cloudflare. Under Caching Configuration
    – Caching level is Standard
    – Browser Cache TTL is 4 hours

  3. Site is also configured with LiteSpeed
    – All pages are cached with LiteSpeed
    – And Public pages are cached for 1 week in LiteSpeed

Where can I check for further information that results in intermittent cache hits for Cloudflare. I am unclear if this is actually a Cloudflare issue, or if it’s due to my origin server passing the incorrect headers (or information) to Cloudflare

Note: Do not have premium cloudflare to check ligs etc.

As an additional piece of information, please find the screenshot that displays all the response headers returned from my site:

My site can be found at https://petcoach.sg

Do let me know if further information would be useful.

The Edge Cache Time to Live is just a maximum, not a guaranteed amount. Cloudflare will evict files far before then if they are not accessed frequently. Additionally, the default Cloudflare cache is per location, and Cloudflare has hunderds of locations, each with their own cache. You can enable Tiered Caching under Caching in the dashboard which is free and dynamically selects a Cloudflare location closest to your origin to check. It’d look something like: Visitor → CF Edge Location (Check cache, return if hit) → CF Tiered Caching Location (Check Cache, return if hit) → Origin

If cache hits are very important to you, you could consider Cache Reserve. It uses an R2 Bucket (Cloudflare’s Object Storage) to cache the object for exactly the TTL, but can be slower then your origin in some cases, and so unless your origin is very slow I probably wouldn’t use it. It also is a paid addon.

The more requests your website gets, the more it’ll be in cache, the faster it’ll be, works out well. You just can’t force Cloudflare to cache your site on every edge if you aren’t getting enough requests.

3 Likes

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