How to get browsers AND Cloudflare to cache a single page on your WordPress site

I spent a few hours this morning figuring out how to get Cloudflare to cache in its CDN a single page on my WordPress blog running under Apache httpd. I wrote up my lessons learned here, on the off chance that it might be useful to someone else:

Pretty cool rundown.

I see you’ve set Cache Everything, but didn’t set an Edge Cache TTL. Why not? When I cache a single Wordpress page, I add a similar page rule, but add that Edge Cache TTL to 6 or so hours, depending on the website’s purpose and update frequency.

With that in mind, do you have any stats on how long that Cache Everything keeps a copy of that page in Cloudflare’s cache?

1 Like

According to https://support.cloudflare.com/hc/en-us/articles/200168376-What-does-edge-cache-expire-TTL-mean-, Cloudflare respects caching headers from the origin, so since I’m setting max-age=3600 in the headers I’m sending for this page from my blog, Cloudflare’s CDN should respect that and refresh its copy of the page every hour.

However, that same page also says that the minimum edge cache TTL setting for the free plan – which is what I’m on – is 2 hours. I don’t know whether that minimum is also applied to the caching headers sent from the origin server. If so, then that would mean that if the origin server’s caching headers say to refresh less frequently than every two hours, that will be respected, but if they say more frequently than every two hours, refreshes will be limited to every two hours.

I change this page infrequently enough that I’m not particularly worried about the Cloudflare’s CDN caching a stale version of it. If I do make a change that I want to get out quickly, I can just purge the cache from the Cloudflare dashboard.

1 Like

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