Cloudflare Cache Everything Improves WordPress TTFB By 90%

Cloudflare cache everything fast site load

You know site speed is a crucial factor for your blog. Cloudflare cache everything can really help you speed things up.

Your visitors won’t wait for more than a couple of seconds for your web pages to load before they leave. Google makes it clear that response time is a significant factor in search ranking. So yes, speed matters today for your site.

It is relatively easy to get reasonable page load speeds for desktop with WordPress. But mobile speed is not quite as easy.

However, there is a way to improve your site speed dramatically with Cloudflare page rules.

Are you using Cloudflare?

The first step to improving your server-side response times is to have your site running on a CDN (Content Delivery Network).

The most popular service is Cloudflare for most bloggers because it is highly effective, reliable, and free.

If you need to add your site to Cloudflare, this tutorial by WP Beginner is an excellent place to start.

But if you are already using it, you can dramatically improve the performance of your time to first byte (TTFB).

It is one of the most critical factors for site loading speed.

In an earlier article, I wrote about improving speed for WordPress admin pages with three page rules.

But for this fix, you need to use the Cloudflare cache everything rule.

If you are using a free Cloudflare account, you only get three page rules.

So it will require changes to your existing page rules.

But it’s worth the effort.

 

Reducing TTFB

Here are some examples of how much difference these changes can make to your TTFB speed.

The two images below, taken using Chrome Deleveopers Tools, show how much difference you can make to your mobile speed.

The first is not optimized and has a TTFB of 1.55 seconds.

TTFB mobile

 

You can see the improvement here after adding the new Cloudflare rule.

TTFB is now only 33.25 milliseconds.

Cloudflare Cache Everything TTFB mobile

 

From my Freshping account, you can see the overall response times for the three sites I optimized.

They are 90% faster than the four sites not yet fully cached.

Cloudflare cache everything response times

It’s proof that using Cloudflare Cache Everything can make an enormous difference.

 

How to apply Cloudflare cache everything

Before you jump into making these changes, a word of warning.

This method is only suitable for a reasonably static site that doesn’t change very often.

It is not a good idea if you have dynamic content such as changing widgets, Twitter feeds, sliders, or regular updates of information.

When you add cache everything to Cloudflare, it does what it says.

Here is how you can add this site speed improvement from your Cloudflare dashboard.

To start, you will need to add your new rule. Click on the page rules app button in the top menu.

If you already have three rules, you will need to delete one. In my case, I deleted the *preview=true* rule.

new page rule

Now add your new page rule for your website URL with a wildcard star at either end.

Then, add these rule settings.

Browser Cache TTL – 1 hour
Cache Level – Cache Everything
Edge Cache TTL – 7 days

Click save, and everything is now set for your cache control headers.

One important note is to check and make sure that you order your rules as in the image above.

Your site cache rule must come after your wp-login and wp-admin rules to protect the origin cache control of your admin pages.

You should also check your Cloudflare browser cache settings to make sure that you have selected Respect Existing Headers.

browser cache ttl

 

Check Rocket Loader

You might also want to check if you are using Cloudflare’s Rocket Loader.

When it works, it works extremely well, but it can also break your site. I have it running on two sites, and it is fine.

But on another site, it causes problems, so I turned it off.

Once you check that all the settings are correct, go to your site to see if everything is working as expected. It should be loading almost instantly now.

Then check your site speed with Google Page Speed Insights, GTMetrix, or Pingdom to see the improvement.

Your aim should be under 200 ms for TTFB and under 2 seconds for fully loaded.

Here is a screenshot of the load timing for one of my sites on GTMetrix. You can see that it is fully loaded in only 0.6 seconds.

page load time

 

One drawback and the solution

Because everything on your site is now cached, any changes you make will not take effect until the cache cycle clears.

This can take a long time to happen.

Therefore, when you add a new post or edit an existing post, you won’t see the changes. It also applies to new comments on your site.

The only way around this is to install the Cloudflare plugin.

I don’t like adding more plugins, but this one is essential for this speed fix.

Once you add it, change the Automatic Cache Management to on.

It will now purge individual files you create or edit and then cache the new files from your origin web server.

You can also purge your whole site from the plugin, but this action will increase your load time until the cache is reloaded.

If you want to bypass cache issues and investigate any problems, it is better to pause your website on Cloudflare.

The button you really shouldn’t click is the Optimize Cloudflare for WordPress.

If you do, it changes many settings that may not be desirable for you. These include minifying HTML, Javascript, and CSS and also changing your existing header settings.

 

Update: A new and much better solution

Since writing this article, a new free WordPress plugin has become available that solves almost all of the issues with Cloudflare Cache Everything.

Super Page Cache for Cloudflare

Super Page Cache for Cloudflare is easy to install and gives you a lot of control.

The plugin helps you cache not only the static files (e.g., CSS, JS, images, etc.) but also the HTML webpages generated by WordPress, both at the server disk-level and on the global Cloudflare CDN.

I installed it on one of my sites, and it worked flawlessly. The TTFB dropped from nearly a second down to less than 0.2 seconds.

speed results

It is comparable to Cloudflare APO, which is not a free service.

But if you use a free Cloudflare account, this free plugin will do almost everything that APO can do.

I use this caching plugin on Just Publishing Advice, and it makes it easy to get a great Core Web Vitals result.

Google Page experience mobile

You can check any page on this site with PageSpeed Insights or GTMetrix to see how well cache everything works.

I’d be surprised if you didn’t get a full green result.

GTmetrix JPA site perfomance

If you want to improve your loading speed and Core Web Vitals, it really is worth taking a look.

 

Summary

Cloudflare Cache Everything works very well and will speed up your site enormously. It is especially effective for improving mobile site speed.

But it is not for every site, and there can be drawbacks depending on your theme, functionality, and site design.

This caching method is very aggressive, so double-check everything.

Ideally, you should try it on a staging or sandbox site to ensure that your site works without any problems.

If you implement it on your live site and run into problems, you can always remove the page rule. Then, fully purge your site on Cloudflare.

You will then be back to where you started.

 

Related Reading: The Best Cloudflare WordPress Page Rules For Admin Pages

Scroll to Top