Cloudflare full page caching – part 1

WordPress is a great CMS, really powerful and flexible. But the downside that comes with that is that is can be rather slow, when not properly optimised.  And even if it has been properly optimised, you’re still hitting the database a lot of the time, and this can really slow things down under heavy load.

The way that a lot of performance boosting plugins deal with this is to cache the HTML of each page.  They take the rendered markup, store it locally in a file, and then when that page is accessed again, the file is returned instead of re-generating all the HTML.  This can give quite noticeable improvement.

Cloudflare is a service I’ve written about many times before, and it’s great for caching your website in each of it’s 194+ (and counting) edge nodes, which can hugely reduce latency.  It would also hugely reduce the load on our origin server, as it would not need to process all the PHP in order to generate the content, nor would it need to contact the database for all the settings and content that is held in there.  This means that if we can get Cloudflare to cache our full page HTML then this would be significantly better than anything a WordPress plugin alone could achieve.

However, by default, Cloudflare will only cache static assets, such as stylesheets and javascript, not dynamically generated content from PHP files.  So how can we change this to take full advantage of the Cloudflare network?

What we’re going to do falls into two discrete chunks; firstly we’re going to add a Worker to Cloudflare to perform the caching, and secondly we’re going to install a WordPress plugin to automatically manage the cache when things change.

I’m going to pause here for dramatic effect, and cover these in my next blog post!

If you can’t wait, I’ve covered this in detail in my Setting up Cloudflare and WordPress course, available on Skillshare and Udemy.