Help me decide a good (best?) caching policy

Two things about my website beforehand: (1) my site is 100% static (including HTML) and (2) my site only gets updated on Saturday. I also use the ‘cache everything’ feature.

Now what would be most beneficial to my website speed?

  1. Set the HTML caching to 1 hour. That way when I update in the weekend, people see the new HTML quickly.
  2. Cache the HTML till next Saturday with the cache-control header. That way everyone who visits the website during the week has a chance to do so from their browser cache (if they visited earlier in the week).

In theory option 2 is quicker. But Cloudflare’s data centres also maintain their cache on a FIFO basis, with assets that are requested less stored less long in the cache. So when I cache the HTML more aggressively the odds of cache MISS are greater (because my files will be requested less). That would in the end give more roundtrips to the origin server, and that’s something I hope to avoid.

What are your thoughts? :slight_smile:

That’s a nice schedule. I recommend you add a Page Rule for with the following settings:
Cache Level: Cache Everything
Edge Cache TTL: 1 Week
Browser Cache: 1 Day

After your Saturday update, you could just go to your Cloudflare Cache page and Purge Everything. Or create a cronjob on your server to make an API call to purge the cache.

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