How to Set Up Cloudflare for WordPress

Cloudflare speeds up websites and protects them from attacks – it’s what they’re known for. WordPress runs millions of sites but often slows down when traffic grows.

Put the two together and you get a faster 🚀, safer 🛡️ site that’s easier to manage 🙌. That’s what this post shows you. I’m going to show you how to set up Cloudflare for WordPress.

I’ll start at Cloudflare itself, where you set up your domain first. That’s the first step before touching WordPress. Then I’ll show how to connect Cloudflare with WordPress so you can use all of its features.

This guide is for anyone running a WordPress site who wants better speed and security without guesswork and without actually having to spend any additional money.

Quick setup overview:
1) Create your free Cloudflare account.
2) Review your DNS records.
3) Change your domain’s nameservers to Cloudflare.
4) Wait for nameserver propagation and verify activation.
5) Optionally connect WordPress to Cloudflare using either the official Cloudflare plugin/APO route or a third-party caching plugin such as Super Page Cache.

Let’s get into it! But first:

How does Cloudflare benefit your WordPress site? 💡

If you’re not familiar with Cloudflare, here’s a rapid-fire list of some of the benefits of using Cloudflare for WordPress:

  • CDN – Cloudflare’s content delivery network helps speed up your site by serving your static content from a huge network of global servers. Cloudflare offers a widely used free CDN and security layer for websites.
  • DNS – Cloudflare is one of the fastest DNS providers (data), which can speed up your site’s time to first byte (TTFB) a lot.
  • Security rules – Cloudflare lets you set up custom security rules to secure specific parts of your site, like your WordPress dashboard.
  • DDoS protection – Cloudflare can help you protect against distributed denial of service (DDoS) attacks. It can also help you just generally filter out malicious traffic.
  • Other performance benefits – Cloudflare can help you minify your code, enable Brotli compression, and implement other performance best practices.

How to set up Cloudflare for WordPress 🤔

Before you can start configuring the other options in Cloudflare, you need to connect your site to Cloudflare.

Long story short:

In order for Cloudflare to work, it needs to be able to manage your domain’s nameservers so that it can serve up cached content from its CDN and filter out malicious actors.

To do that, you’ll need to change your domain’s nameservers to Cloudflare, which is what most of the basic setup process entails.

Here’s how to do it:

1. Create your free Cloudflare account

To get started, go to Cloudflare and sign up.

On the next page, you can enter the domain name of the WordPress site that you want to use with Cloudflare and click Continue at the bottom of the page.

Cloudflare Add a site screen with domain entry field during account setup

Next, you’ll be prompted to choose a plan. You can choose the Free plan confidently, as it offers all the features most WordPress sites need:

Cloudflare plan selection page highlighting the Free plan option

2. Verify DNS records

Once you choose your plan, Cloudflare will scan your site’s DNS records.

If you’re not sure what’s going on here, don’t worry. The only thing you need to verify is that you see an orange cloud next to your main domain name (which you should see by default – no action required):

Cloudflare DNS review showing proxied status (orange cloud) for the apex domain

Simply click on Continue to activation.

Cloudflare activation confirmation screen after reviewing DNS records

3. Update your domain’s nameservers to point to Cloudflare

Now, Cloudflare will give you a new set of nameservers to replace your existing nameservers:

change wordpress site nameservers to cloudflare

Nameservers are part of what you use to connect your domain name to your web hosting. When you switch to Cloudflare’s nameservers, Cloudflare is able to direct traffic to your website. It uses this power to:

  • Filter out malicious traffic – it will send regular traffic to your website just like normal, while filtering out malicious actors before they can reach your site.
  • Deliver static content from the closest server in its huge global network (the CDN part)

How you will change your nameservers depends on where you registered your domain name. Here are tutorials for some of the most common domain name registrars:

Here’s what it looks like at Namecheap…

First, here’s how my domain name was configured before connecting it to Cloudflare:

Namecheap domain settings showing default nameservers before switching to Cloudflare

And here’s what it looks like after updating my nameservers to point towards Cloudflare:

Namecheap domain settings with custom nameservers updated to Cloudflare

Once you’ve changed your domain’s nameservers, go back to the Cloudflare interface and click Check nameservers now.

Cloudflare overview page in pending state with Check nameservers now button

⚠️ Nameservers can take up to 48 hours to update, so you might need to wait a bit for Cloudflare to update. Don’t panic and think you made a mistake unless it’s been at least 24 hours.

4. Verify that your connection is complete

Once your new nameserver settings have propagated, you’ll see a success message like this one in your Cloudflare panel:

Cloudflare dashboard showing successful nameserver activation for the domain

And that’s it! You just set up Cloudflare to take care of your website and work behind the curtains to make your site much faster.

The core steps of the process are now done, but we can actually go much further and configure your WordPress setup to take full advantage of Cloudflare and all its abilities. The thing is that, by default, WordPress doesn’t have any specific customizations or settings for proper Cloudflare integration. Luckily, there are a few ways to make it all work, depending on whether you want to use Cloudflare’s official plugin/APO route or a third-party full-page caching plugin.

In this next section, I’m going to show you one optional route: using the Super Page Cache plugin to make your WordPress website work better with Cloudflare’s caching features.

How to 10x your Cloudflare setup and go to sub-1-second load times 🚀

We’re going to use the free Super Page Cache plugin.

It’s a third-party option that can set some custom Cloudflare optimizations for your site and let you hook up to Cloudflare’s CDN edge network and advanced caching.

If you’d rather stick with Cloudflare’s own ecosystem, you can also explore the official Cloudflare WordPress plugin and APO path instead. Super Page Cache is simply one good optional route if you want fuller page caching from WordPress.

What this means in plain English is that Cloudflare will take your site’s content and deliver it to your visitors through its own network of servers, which results in much faster load times and thus better overall experience for your audience.

The installation is very simple:

a) Install the plugin from the WordPress dashboard

Just put in “Super Page Cache” into the plugin search field, and then install and activate the plugin:

WordPress Plugins page with Super Page Cache plugin result selected for install

b) Enable the main features

Go into Super Page Cache → Settings.

On the General tab, make sure that the Enable Disk Page cache toggle is switched on:

Super Page Cache settings General tab with Enable Disk Page Cache turned on

Then, switch to the Cloudflare tab (labeled Cloudflare – CDN & Edge Caching) to set the main integration:

Super Page Cache Cloudflare tab showing authentication mode and caching options

The main thing to do here is choose your Authentication Mode. The recommended option is API Token, though the plugin also supports the older API Key method.

c) Get your Cloudflare API Token

Go back to Cloudflare, click on your profile image in the top right, and go into API Tokens.

Cloudflare user profile API Tokens page with option to create a token

Create a new token and use the WordPress template if it’s available. Once Cloudflare generates the token, copy it and go back to your WordPress dashboard.

If you prefer, you can still choose the plugin’s API Key authentication mode instead. In that case, you’ll enter your Cloudflare email address and Global API Key. But for most new setups, API Token is the better option.

d) Enter your credentials in WordPress

You’re looking at the following panel again:

cloudflare tab in super page chache plugin

Choose API Token in Authentication Mode and paste your token into the API Token field. If you’re using the older method instead, switch the dropdown to API Key and enter your Cloudflare Email and Global API Key.

Click on Connect to Cloudflare.

In case you have more domains hooked up to your Cloudflare account, pick the correct one from the Select Domain dropdown. Then click on Save Domain.

Super Page Cache Cloudflare settings with Select Domain dropdown and Save Domain button

Lastly, switch the Enable Cloudflare CDN & Caching toggle to on, and click on Update Settings.

Super Page Cache setting to enable Cloudflare CDN and caching with Update Settings button

At this stage, your WordPress site has been successfully integrated with Cloudflare – and with all of Cloudflare’s advanced caching features working in your favor.

Video tutorial

If you’d prefer to see it all done on screen, here’s a step-by-step guide on how to connect your WordPress site with Cloudflare and make it load sub one second:

Get started with Cloudflare for WordPress today 🏁

If you want to speed up and protect your WordPress site, Cloudflare is one of the best free services that you’ll find.

While the setup process requires a little effort with changing your domain’s nameservers, it’s a one-time thing and, going forward, your site will benefit without you raising a finger.

In short: the required setup is to create your Cloudflare account, review DNS records, and point your domain’s nameservers to Cloudflare. The optional optimization path is to connect WordPress with either Cloudflare’s official plugin/APO route or a third-party plugin such as Super Page Cache if you want additional page-caching controls.

Again, the basic process to use Cloudflare for WordPress is to:

  1. Create your free Cloudflare account.
  2. Change your domain’s nameservers to point to Cloudflare’s nameservers.
  3. Optionally connect WordPress to Cloudflare using either the official Cloudflare plugin/APO route or a third-party plugin such as Super Page Cache.

For some other ways to speed up your WordPress site, check out our guides to:

Do you still have any questions about using Cloudflare with WordPress? Let us know in the comments section!

Yay! 🎉 You made it to the end of the article!

0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments