Home » Blog » Performance » WordPress CDN Guide: Cloudflare Setup Done Properly
Performance

WordPress CDN Guide: Cloudflare Setup Done Properly

Terminal-style illustration of a proper Cloudflare CDN setup for WordPress: nameserver move, Full (strict) SSL and edge caching cutting TTFB for distant visitors

“Just use a CDN” is one of the most repeated pieces of WordPress speed advice, and one of the least explained. A WordPress CDN can genuinely transform load times for visitors on the other side of the world from your server – or it can do almost nothing while adding a new layer that occasionally breaks your checkout. The difference is not the CDN itself; it is whether it was configured for how WordPress actually works. After setting up Cloudflare on well over a hundred client sites, I can tell you that most installations I inherit are running on defaults that cache almost nothing useful, with an SSL mode that quietly undermines their HTTPS, and with “optimisation” toggles switched on that fight the caching plugin already installed.

This guide is the version I wish clients had read before they clicked the orange cloud. It covers what a CDN does and – just as important – what it does not, an honest test for whether your site needs one at all, a full Cloudflare setup walk-through on the free plan, the caching configuration that makes the real difference for WordPress, which settings to enable and which to leave alone, cache purging in day-to-day workflows, the security extras you get on the way, the classic “Cloudflare broke my site” cases with fixes, and how to measure the result properly instead of refreshing from your own desk.

Table of contents

What a CDN actually does – and what it does not

A content delivery network is a set of servers spread around the world that keep copies of your files close to your visitors. When someone in Sydney requests an image from your site, they get it from a CDN node in Sydney instead of your origin server in Frankfurt. For static assets – images, CSS, JavaScript, fonts – this is a straightforward win: the round trip drops from 300 milliseconds to under 20, and your origin server does less work because the CDN absorbs most requests.

Here is the part the “just use a CDN” advice skips: by default, the CDN only handles those static assets. The HTML document itself – the response WordPress generates when someone requests a page – still comes from your origin server on almost every CDN setup, because HTML is dynamic: it differs for logged-in users, cart holders and form submitters. That matters because the HTML response is what determines time to first byte (TTFB), and TTFB is where geography hurts most. A visitor in Melbourne requesting a page from a German server waits for the full round trip plus PHP execution before anything happens. So a default CDN setup speeds up the second half of your page load and leaves the first half untouched.

Getting the CDN to cache full HTML pages – safely, with the right exceptions for WordPress – is where the dramatic numbers come from, and it is precisely the part that requires deliberate configuration. We will do that properly in the caching section. The other honest caveat: a CDN does not fix a slow site. If your pages take three seconds of PHP and database time to generate, the CDN faithfully delivers that slowness worldwide, minus a bit of latency. Fix the basics first – I have written a complete guide to speeding up a WordPress website that covers the order of operations.

Do you actually need a CDN? The audience geography test

The honest answer is: it depends almost entirely on where your visitors are relative to your server. The test takes ten minutes:

  • Open your analytics and list the countries that produce 90% of your traffic. Not the long tail – the real audience.
  • Find your server’s physical location. Your host’s dashboard usually says; if not, ask support. Good hosting choice matters more than any CDN, which is why I cover location in my guide to choosing WordPress hosting.
  • Estimate the distance. Same country or a neighbouring one: latency is already 10-40ms and a CDN’s geographic benefit is small. Different continent: latency is 100-300ms per round trip and a CDN helps a lot.

A German plumber with a German server and 95% German traffic will not see the transformation the marketing promises – the assets already arrive quickly. That site might still want Cloudflare for other reasons (free SSL management, DDoS protection, hiding the origin IP, the firewall), but “the site will get dramatically faster” is not one of them, and I tell clients that plainly. The opposite case is common too: an Australian shop on cheap US hosting, or a UK consultancy with half its readers in North America and Asia. Those sites gain enormously – often more from CDN configuration than from any plugin tuning.

There is a third case: high-traffic sites where the CDN’s job is less about geography and more about absorbing load – serving cached copies so your origin survives spikes. If that is your situation, this guide pairs with my post on scaling WordPress for high-traffic websites, where the CDN is one layer of several.

Cloudflare setup walk-through, step by step

I use Cloudflare as the reference because its free plan is genuinely useful, not a crippled trial: unlimited bandwidth, a global network, free SSL, HTTP/3 and enough rules for a normal WordPress site. Here is the setup order that avoids the classic mistakes.

Step 1: Add your site and check the imported DNS records

Create a Cloudflare account, add your domain, and let it scan your existing DNS records. Then compare the imported list against your current DNS zone line by line – the scan is good but not perfect, and a missed MX or verification TXT record means broken email a day after you switch. Copy anything missing manually before you go further. This five-minute check is the difference between a smooth move and a support ticket storm.

Step 2: Move your nameservers at the registrar

Cloudflare gives you two nameservers (something like ada.ns.cloudflare.com). You change to them at your domain registrar – not your host. From that moment Cloudflare answers DNS for your domain. Propagation usually completes within an hour, sometimes a few. Nothing visible changes yet if the records were copied correctly, which is exactly what you want.

Step 3: Understand the proxy toggle before you trust it

Every DNS record in Cloudflare has a cloud icon. Orange cloud (proxied) means traffic for that record flows through Cloudflare’s network – you get the CDN, caching, SSL and firewall. Grey cloud (DNS only) means Cloudflare only answers the DNS query and traffic goes straight to your server – no CDN, no protection. Your main A record and the www record should be orange. Records for mail, FTP or direct server access must stay grey – proxying mail records breaks email. Half the “Cloudflare does nothing for my site” cases I audit turn out to be a grey cloud on the main record.

Step 4: Set SSL mode to Full (strict) – and nothing else

This is the single most important setting in the whole dashboard. Cloudflare terminates HTTPS at its edge and then connects onwards to your origin, and the SSL/TLS mode controls that second connection. Full (strict) means Cloudflare connects to your origin over HTTPS and verifies a valid certificate – end-to-end encryption, done properly. Flexible means Cloudflare talks to your origin over plain HTTP while showing visitors a padlock: the leg between Cloudflare and your server is unencrypted, and WordPress redirect loops are a common side effect. Flexible exists for legacy servers without certificates, and with Let’s Encrypt free on practically every host (or a free Cloudflare Origin Certificate you can install in minutes), there is no excuse for it. Install a certificate on your origin, pick Full (strict), and switch on “Always Use HTTPS”. The wider certificate story – issuance, renewal, mixed content – is in my complete SSL and HTTPS guide for WordPress.

Five-step Cloudflare setup for WordPress: add the site and verify imported DNS, move nameservers, set proxy toggles, choose Full (strict) SSL, then configure caching and measure TTFB
The safe Cloudflare setup order for WordPress – SSL mode sorted before caching saves you the classic redirect loop.

Caching configuration: the part everyone skips

With the setup above you have a working CDN – for assets. Cloudflare’s default behaviour caches files by extension: images, CSS, JavaScript, fonts. It explicitly does not cache HTML. This is the safe default and the reason default installations underwhelm. Configuring page caching is where the real gains live, and WordPress needs it done with exceptions.

Why HTML caching needs care on WordPress

WordPress generates different HTML for different people: an admin sees the toolbar, a WooCommerce customer sees their cart count, a commenter sees their name pre-filled. Cache HTML naively and one visitor’s page – toolbar, cart and all – gets served to everyone. Every horror story about page caching comes down to a missing exception, so we define the exceptions first.

Cache Rules: the manual approach

In Caching, create a Cache Rule that switches caching to “Eligible for cache” (the modern equivalent of the old “Cache Everything”) for your hostname, then add the bypasses. The rule logic you want, expressed plainly:

  • Bypass when the URL path starts with /wp-admin, /wp-login.php, /cart, /checkout, /my-account (adjust to your setup).
  • Bypass when a cookie is present containing wordpress_logged_in, wp-, comment_author, woocommerce_cart_hash or woocommerce_items_in_cart. This is the exception that protects logged-in users and shoppers.
  • Set an edge TTL – I use two to four hours for typical business sites, longer for sites that rarely change, always combined with purge-on-update (next section).

The cookie bypass is the part people miss. Without it, the first logged-in user to hit a page can poison the cache for everyone. With it, logged-in users and cart-holders always reach the origin while anonymous visitors – the vast majority on most sites – get pages served from the nearest edge in tens of milliseconds.

APO: the managed approach

Cloudflare’s Automatic Platform Optimization (APO) is a WordPress-specific service (USD 5 per month on the free plan, included with Pro) that does the above for you: it caches HTML at the edge with WordPress-aware logic, handles the cookie exceptions, and purges automatically when you update content, via the official Cloudflare plugin. For non-technical site owners it is honestly the safer choice – the failure mode of a hand-written Cache Rule is subtle bugs, and APO has the exceptions built in. For sites I manage I usually build Cache Rules by hand because I want explicit control, but I recommend APO without hesitation to clients who will maintain the site themselves. Either way, keep your local caching plugin: origin cache and edge cache stack, they do not compete.

Settings to switch on – and settings to leave off

The Speed and Network tabs are full of toggles, and the temptation is to enable everything. Resist it. Some of these features overlap with what your caching plugin already does, and one of them is famous for breaking sites.

Switch on – safe wins on almost every WordPress site:

  • Brotli compression. Better than gzip for text assets, no downside, one toggle.
  • HTTP/3 (with QUIC). Faster connection setup, especially on mobile networks. No WordPress-side changes needed.
  • Early Hints. Sends 103 responses so browsers start fetching critical assets before your server finishes the HTML. Free performance on slow origins.
  • Always Use HTTPS plus a minimum TLS version of 1.2.
  • Tiered Cache. Improves cache hit rates by letting edge nodes fetch from a parent node rather than all hitting your origin.

Leave off – overlap or breakage risk:

  • Rocket Loader. It rewrites how your JavaScript loads, and it breaks things: sliders that never initialise, forms that will not submit, tracking that silently stops. On a well-optimised site your caching plugin already defers scripts with proper exclusions. In a decade of speed work I have switched Rocket Loader off far more often than on.
  • CDN-level minification. Cloudflare retired its Auto Minify feature in 2024, and rightly – minification belongs in your build process or caching plugin, where you control exclusions. If your CDN offers minify, skip it; double-minified JavaScript is a debugging nightmare.
  • Mirage. A legacy image feature from an era before native lazy loading. Modern themes and WordPress core already lazy-load images; skip it.
  • Email obfuscation if you have pages where scripts manipulate email links – it can interfere. Harmless on most sites, but if a mailto link misbehaves, this is the first suspect.

The principle: enable transport-level improvements (compression, protocols, hints) at the CDN, and keep content-level rewriting (minify, defer, lazy load) in WordPress where you can exclude what breaks. One layer per job.

Two-panel comparison of Cloudflare settings for WordPress: switch on Brotli, HTTP/3, Early Hints, HTTPS and Tiered Cache; leave off Rocket Loader, CDN minification, Mirage and Flexible SSL
Transport-level wins go on at the CDN; content rewriting stays in WordPress where you control the exclusions.

Free plan vs paid: where the line sits

I put most small business sites on the free plan and they stay there happily. Here is my honest view of where paying starts to make sense:

Feature Free plan Paid (APO / Pro)
CDN for static assets Yes, unlimited bandwidth Same
SSL, HTTP/3, Brotli, Early Hints Yes Same
HTML page caching Manual Cache Rules (free, DIY) APO: managed, WordPress-aware
Image optimisation (Polish, WebP/AVIF) No Pro – useful if your plugin stack does not convert
WAF rulesets Basic free rules, custom rules limited Managed rulesets on Pro
Cost EUR 0 APO ~USD 5/month; Pro ~USD 25/month

My rule of thumb: the free plan plus hand-built Cache Rules covers a typical business site completely. Pay for APO when nobody technical maintains the site. Consider Pro when you want Polish because your image pipeline does not already produce WebP (most of my builds do, making Polish redundant), or when you want the managed WAF rules on a site that attracts real attack traffic. What I do not recommend is upgrading in the hope of speed: past APO, the paid tiers buy security, analytics and support, not meaningfully faster pages.

Purging cache in real workflows

The moment you cache HTML at the edge, stale content becomes your problem. You update a price, the client refreshes from their office, the old price still shows – because their nearest edge node holds a copy that is valid for another three hours. Purging has to be part of the workflow, not an afterthought:

  • The official Cloudflare plugin purges automatically on post updates and is required for APO. For editorial sites this covers 90% of cases.
  • Caching plugins with integration. WP Rocket, W3 Total Cache and Super Page Cache can purge Cloudflare when they purge locally, keeping both layers in sync from one button.
  • Deploy hooks. On sites with a deployment pipeline I add a single API call – a POST to the Cloudflare purge endpoint with the zone ID and an API token – as the last deploy step. Code goes out, edge cache clears, no human remembers anything.
  • Purge by URL, not everything. “Purge everything” empties the entire edge cache and your origin takes the full load while it refills. Purging the changed URLs keeps hit rates high. Save purge-everything for CSS/JS releases where filenames did not change.

One habit worth teaching clients: when they swear an update is not showing, check from a private window before touching Cloudflare. Roughly half of “the CDN is serving old content” reports are the browser’s own cache.

The security bonuses you get on the way

Even when the performance case is thin, Cloudflare earns its place on security grounds, because proxied traffic means attacks meet Cloudflare before they meet your server. On the free plan you get DDoS protection that has absorbed attacks which would flatten any shared host, your origin IP hidden behind the proxy (keep it hidden – do not leak it via a grey-clouded subdomain pointing at the same server), and free custom WAF rules. Two rules I add to almost every WordPress site: a challenge on /wp-login.php for countries the business does not operate in, and a block on /xmlrpc.php if nothing uses it. That pair quietly removes most of the brute-force noise from the origin logs.

Two cautions from real projects. Bot Fight Mode looks like a free win but challenges indiscriminately – it has broken payment gateway webhooks and uptime monitors on client sites, so if you enable it on a WooCommerce store, test the full order flow including the gateway’s server-to-server callback. And treat the firewall as a complement, not a replacement: Cloudflare filters traffic on the way in, but it does not know whether your plugins are updated or your passwords are strong. WordPress firewalls and WAF strategy deserve their own post, and I have kept the deeper material for that; here it is enough to say the free tier’s protection is real and worth having.

When Cloudflare breaks your site: common cases and fixes

“I enabled Cloudflare and now the site is broken” almost always resolves to one of four patterns:

Redirect loops

The classic cause is Flexible SSL: Cloudflare requests the page over HTTP, WordPress (set to HTTPS) redirects to HTTPS, Cloudflare requests over HTTP again, forever. The fix is never a plugin – it is installing an origin certificate and setting Full (strict). A rarer variant: your host also forces HTTPS redirects while Cloudflare’s “Always Use HTTPS” is on and the SSL mode is wrong. Correct the mode first; the loop usually vanishes.

Challenge loops and blocked admins

A security level set too high, or an over-broad WAF rule, can challenge you on your own wp-admin – and because admin pages set cookies while challenges reset them, you can loop. Fix: a WAF skip rule for your own IP (or your office range), and keep the challenge rules scoped to /wp-login.php rather than everything under /wp-admin.

Cached redirects and wrong content

If you cache HTML while a redirect misfires – say the www redirect briefly pointed somewhere odd – the edge can cache the redirect itself, and visitors keep landing wrong after you fix the origin. Fix: correct the origin, then purge the affected URLs. The same logic applies to a page cached mid-maintenance-mode: purge it, do not wait out the TTL.

Logged-in and cart weirdness

Admin bar showing to anonymous visitors, someone else’s cart count, a checkout that loops back to the cart: all symptoms of HTML caching without the cookie bypasses from the caching section. Fix the rule, purge everything once, and retest as a logged-out visitor, a logged-in user and a shopper with items in the cart. Those three personas are the complete test suite for WordPress edge caching.

Alternatives: when a simpler CDN is the better tool

Cloudflare is a reverse proxy: it takes over your DNS and sits in front of everything, which is what makes the firewall, SSL management and HTML caching possible – and also what makes misconfiguration able to take the whole site down. Sometimes you do not want that power. The BunnyCDN class of service (Bunny, KeyCDN and similar) works differently: you keep your DNS, create a pull zone that mirrors your site’s assets, and a plugin (CDN Enabler, or your caching plugin’s CDN field) rewrites asset URLs to the CDN hostname. Only images, CSS and JavaScript flow through the CDN; HTML and everything dynamic go straight to your origin, untouched.

When is that the better choice? When you specifically want asset offload without handing over DNS – a client whose IT department controls the domain and will not move nameservers, or a site where another system already terminates SSL. The pricing is honest per-gigabyte (Bunny costs a few euros a month for a typical business site) and the blast radius of a mistake is small: worst case, assets 404 and you switch the plugin off. What you give up is everything the proxy model provides – no edge HTML caching, no WAF, no DDoS absorption, no origin IP hiding. My default recommendation remains Cloudflare free because the extras matter, but “simpler tool, smaller blast radius” is a legitimate engineering choice, not a downgrade, and I have deployed both in the same month for different clients.

Measuring the difference properly

The worst way to evaluate a CDN is refreshing your own site from your own desk: you are one location (probably near your server), on a warm cache, on a fast connection. Measure like this instead:

  • Test from where your audience is. Use a testing tool that lets you pick locations (WebPageTest and GTmetrix both do) and run the same page from your top three visitor countries. The CDN’s whole value proposition is geographic; a single-location test cannot see it.
  • Compare TTFB before and after page caching, per location. Asset caching barely moves TTFB; edge HTML caching collapses it. On a recent client project, a Sydney test against a German origin went from roughly 900ms TTFB to under 100ms once Cache Rules served HTML from the Sydney edge. That is the number that proves the configuration works.
  • Check the response headers. The cf-cache-status header tells the truth: HIT means the edge served it, DYNAMIC means the request went to your origin (the default for HTML), BYPASS means a rule sent it past the cache deliberately. If your pages say DYNAMIC after all this, your Cache Rule is not matching.
  • Watch real-user data over weeks. Search Console’s Core Web Vitals report and the CrUX data behind PageSpeed Insights reflect your actual visitors’ experience. Lab tests prove the mechanism; field data proves the outcome.

And measure twice: once logged out (should be edge HITs), once logged in (should be BYPASS with everything working). A CDN configuration that is fast for visitors and correct for editors, on the same URL, is the definition of done.

Want your CDN configured properly – or your whole site made fast?

I set up Cloudflare as part of nearly every WordPress speed optimisation project: caching rules with the right bypasses, SSL done strictly, purge hooks wired into your workflow, and before/after measurements from your actual visitor locations – not marketing screenshots. Have a look at my portfolio, or send me your site and I will reply within 24 hours with what I would change and a fixed price.

Frequently asked questions

Do I need a WordPress CDN?

Only if your visitors are far from your server or your traffic spikes beyond what your origin handles comfortably. A single-market site hosted in that market gains little speed from a CDN, though Cloudflare’s free security extras can still justify it.

Is Cloudflare’s free plan enough for WordPress?

For most business sites, yes: unlimited-bandwidth CDN, free SSL, HTTP/3, Brotli and enough Cache Rules for proper page caching. Pay for APO if nobody technical maintains the site, or Pro if you need Polish or managed WAF rules.

Does a CDN improve TTFB?

Only if it caches your HTML at the edge. Default asset-only caching leaves TTFB almost unchanged because the HTML still comes from your origin; Cache Rules or APO are what collapse TTFB for distant visitors.

Which Cloudflare SSL mode should I use with WordPress?

Full (strict), always. Install a Let’s Encrypt or Cloudflare Origin certificate on your server first. Flexible mode leaves the Cloudflare-to-origin leg unencrypted and routinely causes redirect loops.

Why did my site break after enabling Cloudflare?

The usual suspects: Flexible SSL causing redirect loops, Rocket Loader breaking JavaScript, HTML caching without cookie bypasses showing wrong content, or a security rule challenging your own admin. Each has a specific fix covered above.

Does Cloudflare cache WordPress pages by default?

No – by default it caches static assets only and marks HTML as DYNAMIC. You must add Cache Rules with WordPress-aware bypasses, or use APO, to get edge page caching.

Is BunnyCDN better than Cloudflare for WordPress?

It is simpler, not better: assets-only offload without moving DNS, for a few euros a month. Choose it when you cannot or will not proxy DNS; choose Cloudflare when you want page caching, the firewall and DDoS protection too.

Vishal Bhisara

Written by Vishal Bhisara

Full Stack WordPress Developer & AI Solutions Expert with 12+ years of experience and 500+ projects delivered worldwide. I help businesses and agencies build fast, secure, SEO-ready websites - custom themes, plugins, WooCommerce stores, and AI automation that actually grows revenue. Based in Bhavnagar, India, working with clients across the globe. More about me →

Need Expert WordPress Support?

Reading great content is the first step. Implementing the right strategy is what delivers results. If you need professional help with your WordPress website, WooCommerce store, AI automation, or custom development project, I'm here to help.

Have a Project in Mind? Let's Make It Happen.

Start a Project
Vishal Bhisara
Vishal Bhisara Your WordPress & AI partner
Get a Free QuoteGet a Free Quote