Start » WordPress » Speed & Optimization » How to configure Cloudflare for WordPress

How to configure Cloudflare for WordPress

In this article, I’ll explain how I’ve configured Cloudflare for my WordPress websites so that they are as fast and as secure as possible, while working properly. For this example I’ll use a free Cloudflare account, that is available to everyone without any extra costs. In separate articles, I explained what Cloudflare is, and how to configure Cloudflare DNS.
Most of the settings shown here will work for a vast majority of websites, not just for WordPress.


Table Of Contents (T.O.C.):

  1. Introduction
  2. Overview
  3. Analytics
  4. DNS
  5. Email
  6. SSL/TLS
  7. Firewall
  8. Access
  9. Speed
  10. Caching
  11. Workers
  12. Rules
  13. Network
  14. Traffic
  15. Stream
  16. Custom Pages
  17. Apps
  18. Scrape Shield


0. Introduction

Cloudflare is an excellent service that provides a lot of speed, security and ease of use (when migrating websites etc.) even 100% free of any cost (in more details: what is Cloudflare?).

At the time of writing this, Cloudflare has 17 main menu options, with each of those often having several sub-options. I’ll use that structure to show and explain all the settings I use and recommend. The options where nothing needs configuring will be just skipped.

17 Cloudflare main menu options, with the 5 sub-options shown for the fifth main menu item
17 Cloudflare main menu options, with the 5 sub-options shown for the fifth main menu item

Everything written here is based on my knowledge and experience with several WordPress websites over the past years (I’ve been using Cloudflare with WordPress since 2018). This is how I configure Cloudflare and what works for me, but you are following all the advice at your own risk (responsibility). I.e. use reasonable caution and common sense, and don’t blame me if something goes wrong. 🙂

– T.O.C. –


1. – 4. Options 1 (Overview) through 4 (Email)

Overview and Analytics menus are informative. They contain basic info about your account but have no configuration options, so we won’t be going into those – they are quite clear and intuitive (self-explanatory as the Americans say).

DNS options are all nicely explained in the article on how to configure Cloudflare DNS. I suggest you read it and configure your DNS properly – without it, none of the options shown here will work.

Email – a new service from Cloudflare. I prefer using MXroute and have dedicated a separate article to configuring MXroute email service.

– T.O.C. –


5. SSL/TLS

5.1. Overview

  • Set the first option to “Full (strict)
    If your server hasn’t got a configured SSL/TLS certificate, it won’t work with this setting. Separate articles explain how to install SSL/TLS in cPanel, and DirectAdmin SSL/TLS installation.
  • SSL/TLS RecommenderON
    Doesn’t hurt to activate this, so Cloudflare can notify you via an email if your current encryption method can be improved.

5.2. Edge Certificates

  • Edge Certificates – Cloudflare takes care of this automatically, for free. No need to touch anything. For my domain it says (and your domain should show the same pattern):
    *.bikegremlin.com, bikegremlin.com, and “Status Active”.
  • Always Use HTTPS – OFF
    I like keeping this turned off, then checking if my website and server are configured to serve everything using HTPPS. Turning it on does no harm, but I like being sure my websites can work properly even without Cloudflare (in case they start charging an arm and a leg, or their service quality becomes poor).
  • HTTP Strict Transport Security (HSTS) – OFF
    Don’t enable this. I explained here why I think HSTS can make your life more complicated.
  • Minimum TLS Version1.1
    This defines the lowest TLS version your website will allow connections with. Don’t go with a lower version (1.0). Modern browsers and computers will of course use the latest. Version 1.0 (SSL) is considered insecure now and should not be allowed.
  • Opportunistic EncryptionON
    This isn’t a HTTPS replacement, but it provides encryption even for other protocols, such as HTTP/2.
  • TLS 1.3ON
  • Automatic HTTPS Rewrites – OFF
    If this is enabled, Cloudflare will try to serve all the links, including the non-HTTPS ones, using the HTPPS protocol (if it’s available for the link/resource). Similar to the “Always Use HTTPS” option: it doesn’t hurt to turn this ON, but I think it’s better to see if some of your links or images aren’t set to HTTPS, and fix that.
  • Certificate Transparency MonitoringBetaON
    Cloudflare will scan the public lists of issued TLS/SSL certificates, and notify you if a certificate for your domain has been issued. Unless you (or your hosting server) have renewed the certificate, it’s good to know that someone else has managed to get a certificate for your domain.
  • Disable Universal SSL – Don’t click on this option, unless you wish to manually configure SSL/TLS certificates for Cloudflare.

5.3. Client Certificates

Don’t touch anything here.

5.4. Origin Server

If you can’t install certificates on your hosting server (this usually requires admin access), don’t touch anything here. That is:

  • Origin Certificates – Don’t click on this.
  • Authenticated Origin Pulls – OFF

We’ll also skip the next sub-menu, “Custom Hostnames.”

– T.O.C. –


6. Firewall

We’ll skip the sub-menus “Overview,” “Managed Rules,” and “Firewall Rules.” Those are for special use cases and are beyond the scope of this article. For most websites it’s perfectly fine to not touch anything there.

6.4. Bots

  • Bot Fight Mode – OFF
    If you enable this, WordPress REST API and Loopback requests won’t work properly.

We’ll now also skip the “DDoS” and “Tools” sub-menus. This is fine left on default. Even moderate-scale bot attacks can be solved using the following sub-menu options, as I’ll explain.

6.7. Settings

  • Security LevelMedium
    Set this to “High” or “I’m Under Attack!” if you are having bot attack problems. Try “High” first – it often does the job, without bothering legit visitors with reCAPTCHA.
  • Challenge Passage1 hour
  • Browser Integrity CheckON
  • Privacy Pass SupportON

– T.O.C. –


8. Speed

As you can see, we’ve skipped the “Access” menu (nothing to touch there) and moved up to “Speed” (pun intended). 🙂

8.1. Overview

The important thing here is the button for buying Cloudflare service for caching WordPress websites from Cloudflare edge servers, by using Cloudflare WordPress APO (CF website link).

Option for purchasing Cloudflare WordPress APO
Option for purchasing Cloudflare WordPress APO

This costs $5 per month. Yes, you can make your website run fast without it (my series of articles on website optimization). And yes, you can use various tricks to achieve something similar. The main problem when going free, is to “bypass cache on a browser cookie,” i.e. to avoid showing cached admin pages to visitors and vice-versa.

The speed boost is excellent when pages are pre-created (cached) and served from Cloudflare’s servers directly to visitors. Again, websites can be pretty fast even without this, so you can save $5. If you have a web-shop, especially if you are selling the stuff people don’t really need, so giving them half a second more to think is detrimental for the sales, pay the $5, it’s well worth it. For non-profit websites, it makes no sense to pay for this (I should ask Cloudflare to sponsor me, so I could make a comparison test/review and publish the results 🙂 ).

8.2. Optimization

  • Image Resizing – Pro option (for paid Cloudflare plans)
  • Polish – Pro option
  • Auto Minifycheck all the boxes (JavaScript, CSS i HTML)
  • BrotliON
  • Early Hints – still in the beta test phase. I’d be happy to test and provide feedback for a reasonable compensation. 🙂
  • Automatic Platform Optimization for WordPress – You can buy Cloudflare WordPress APO from this menu as well, very convenient.
  • Enhanced HTTP/2 Prioritization – pro option (not for us poor guys 🙂 )
  • TCP Turbo – Pro option
  • Mirage – Pro option in beta test phase (you pay to test it 🙂 )
  • Rocket Loader™ – OFF
    This mostly works fine when enabled. I had to disable this so Google Programmable website search would work properly. At least until I figure out what scripts exactly does the search use, so I could “bridge” only those – Cloudflare documentation on Rocket Loader specific JavaScript ignoring.
  • Automatic Signed Exchanges (SXGs) – Pro option in beta test phase
  • Prefetch URLs – Enterprise option
  • AMP Real URL – OFF
    Activating this shows real website URLs for AMP website version. I want the AMP website version to be clearly noticeable.
  • Mobile Redirect – OFF
    Those with a separate website (sub)domain for the mobile website versions could wish to enable this.

Skipping the “Browser Insights” – nothing to see, and moving on.

– T.O.C. –


9. Caching

Skipping the “Overview” and going straight to:

9.2. Tiered Cache

  • Argo Tiered CacheON

9.3. Configuration

  • Purge Cache – clicking the “Purge Everything” button deletes all the Cloudflare cache, which is handy sometimes (minor CSS changes for example). “Custom Purge” gives you a box to enter a list of URLs for which you wish to delete cache (so you don’t delete the entire cache).
  • Caching LevelStandard
  • Browser Cache TTLRespect Existing Headers
    Works best with LiteSpeed Cache plugin.
  • CSAM Scanning Tool – it will search your site for “inappropriate child images” and notify you. On a well secured server you don’t really need this (you know what you upload). But for websites that let community members upload stuff, it could be a good idea.
  • Crawler HintsON
  • Always Online™ON, just don’t click on “Update,” that’s still in a beta test phase.
  • Development Mode – OFF
    Enable this if you wish to bypass Cloudflare service and use it as a DNS only. Usefull during development or troubleshooting, though I prefer to do development in a staging environment, and to “manually” disable one option at a time during troubleshooting.
  • Enable Query String Sort – Enterprise option

– T.O.C. –


10. Workers

Workers options let you do magical stuff, even for free. However, that is a topic for a separate article, or a series of articles, depending on the use case.

– T.O.C. –


11. Rules

11.1. Page Rules

Order of rules is important! For every page visit, the rules list is read from the first to the last. As soon as the first condition of a rule is matched, that rule is executed, and all the following rules (below) are disregarded. Here’s the list of BikeGremlin rules:

A list of Cloudflare Page Rules
A list of Cloudflare Page Rules

The second rule is for redirecting sub-domains that have a www. added (I used to think that’s a good idea 🙂 ) to naked sub-domains.

The first rule is a good idea for any WordPress website, and I’ll show it in detail. If you are using a naked domain (no www.), then remove the dot after the first asterisk, before your domain name.
I think that naked domains are a bad idea (I’m using www.bikegremlin.com, or subdomains, like this one – io.bikegremlin.com).

Cloudflare Page Rule for "wp-admin" protection
Cloudflare Page Rule for “wp-admin” protection

You could make a similar rule for *yourdomain.com/wp-login*
You could also set the “Security Level” to “I’m Under Attack!”

We’ll skip the “Transform Rules” and move on.

11.3. Settings

  • Normalize incoming URLsON
  • Normalize URLs to origin – OFF

– T.O.C. –


12. Network

  • HTTP/2 ON
  • HTTP/3 (with QUIC)ON
  • 0-RTT Connection ResumptionON
  • IPv6 CompatibilityON
  • gRPC – OFF
  • WebSocketsON
  • Onion RoutingON
  • Pseudo IPv4 – OFF
  • IP GeolocationON
  • Maximum Upload Size100MB
  • Response Buffering – Enterprise option
  • True-Client-IP Header – Enterprise option

– T.O.C. –


13. Options 13 (Traffic) through 16 (Apps)

Options under “Traffic,” “Stream,” “Custom Pages,” and “Apps” are mostly paid (Pro and Enterprise options) or for special use cases.

No need to touch anything here. Moving on.

– T.O.C. –


17. Scrape Shield

  • Email Address ObfuscationON
  • Server-side ExcludesON
    This option enables you to use “special” HTML comment tags to hide some content (like a phone number) from “disreputable visitors,” for example: “<!–sse–>my phone here<!–/sse–>
  • Hotlink ProtectionON
    You can switch this of, then use your hosting server (.htaccess file) to configure for which subdomains you wish to allow image embedding to other sites.
    You could also create a directory on your root domain called “hotlink-ok” (like “https://bikegremlin.com/hotlink-ok/”). Any images placed there will be allowed to be embedded, even if you enable hotlink protection.

– T.O.C. –

Interesting fact
I posted this article on Reddit’s WordPress subreddit – and it was removed by the moderators with this note:

Sorry, this post has been removed by the moderators of r/Wordpress.
Moderators remove posts from feeds for a variety of reasons, including keeping communities safe, civil, and true to their purpose.

Unlike this “publishing policy,” members and moderators on LowEndSpirit forum actually encourage making articles like this, often providing constructive criticism, corrections, additions and positive feedback (when deserved). This helps make the articles even better – so they can better help more people. I think this is a great way of improving and sharing knowledge, and helping the community in general.

– T.O.C. –

Leave a Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Google chosen content: