How to Use a CDN with WordPress (Cloudflare Setup Guide)

Set up Cloudflare on WordPress: change nameservers, use Full (strict) SSL, install the official plugin, and enable APO to cache HTML at the edge.

A Cloudflare WordPress setup puts a CDN in front of your site so static files, and optionally HTML pages, are served close to the visitor instead of only from your origin host.

The free plan already proxies assets. Automatic Platform Optimization, or APO, is the add-on that caches HTML at the edge. That is the difference most “just enable Cloudflare” guides skip.

The order that works: point DNS at Cloudflare, set SSL correctly, install the official plugin, then add APO if you want HTML caching, and verify the headers.

⚡ Quick answer

  • Best for: self-hosted WordPress sites that want a global CDN, and sites that also want edge HTML caching once DNS and SSL are stable.
  • Skip it if: you cannot change nameservers (Free and Pro use a full setup), or you run WordPress multisite and were hoping to use the APO plugin, which does not support it.
  • Time needed: 30 to 60 minutes for DNS and SSL, plus up to 24 hours for nameserver propagation, then 15 minutes for the plugin and APO.
  • Our call: Turn on the free CDN first, confirm SSL, then add APO. Pause other page-cache plugins until you have proved APO works, then add them back one at a time.

What a WordPress CDN does, and what APO adds

A content delivery network stores copies of files close to visitors. For WordPress, the usual first win is static assets: images, CSS and JavaScript. That cuts the work your origin server does, which is the same problem we walk through in how to reduce server response time.

Most WordPress cache plugins still build the HTML on or near the origin, then maybe share it between requests. Our WordPress cache plugins roundup is about that layer. A CDN in front is a different layer.

Cloudflare’s official WordPress plugin describes APO as the piece that caches the HTML itself at Cloudflare’s edge and purges it when you update content.

That is why vendor copy talks about larger gains than asset-only CDNs. Treat “up to 300% faster” as marketing language, not a measurement from this guide.

LayerWhat it cachesTypical toolNotes
Origin / host cacheHTML and objects at the serverYour host or a cache pluginFast for repeat visits to the same data center
CDN (proxied DNS)Static assets at the edgeCloudflare Free or Pro, orange-cloud recordsDoes not, by itself, cache WordPress HTML
APOHTML at the edge, with smart purgingCloudflare APO + official plugin$5/month on the Free plan; included with Pro and higher
How a CDN, a cache plugin and Cloudflare APO differ. Prices checked on cloudflare.com and WordPress.org in November 2026.

Edge HTML caching also helps Core Web Vitals that depend on a short first response, which is why this setup belongs in the same conversation as our Core Web Vitals guide and speed optimization walkthrough.

Do this if visitors are spread out geographically, or your origin is slow under load. Skip APO until basic proxying and SSL are stable. A broken certificate plus HTML caching is a painful combination.

What you need before you start

  • Access to the domain registrar, so you can change nameservers. Cloudflare’s Pro plan page (checked November 2026) notes that keeping your current DNS provider with a partial CNAME setup requires Business or Enterprise. Free and Pro use a full setup.
  • A valid HTTPS certificate on the origin, such as Let’s Encrypt from your host, if you want Full (strict) SSL.
  • A Cloudflare account and the site’s current DNS records written down, including mail (MX) and any roots or www records.
  • A backup and a maintenance window. DNS mistakes can take the site and email offline.
  • Optional: a note of any existing cache plugin, including WP Rocket or Perfmatters, because Cloudflare asks you to pause similar tools while you first enable APO.

Step 1: Add the domain and change nameservers

Follow Cloudflare’s full setup documentation.

  1. Log in to the Cloudflare dashboard and choose Onboard a domain.
  2. Enter the apex domain, such as example.com, and import or review DNS records.
  3. Check every record against your host’s DNS list. Mail records should stay DNS-only (grey cloud) unless you know you want them proxied, which you usually do not.
  4. Cloudflare will give you two nameservers. Replace the nameservers at your registrar with those values, then wait for propagation.
Cloudflare documentation steps for adding a domain and changing nameservers in a full DNS setup
Full setup: add the domain, review DNS, then change nameservers at the registrar. Source: developers.cloudflare.com, captured November 2026.

Propagation can be quick or it can take hours. Until Cloudflare shows the zone as active, do not start flipping SSL or APO. If the site or email disappears, the usual cause is a missed record, not “Cloudflare being down.”

Common mistake: changing nameservers before you have reviewed MX and TXT records. Import is not always perfect. Check them first.

Step 2: Set SSL/TLS to Full (strict)

In the Cloudflare dashboard, open SSL/TLS and look at the encryption mode. Full (strict) encrypts visitor-to-Cloudflare and Cloudflare-to-origin traffic, and it validates the origin certificate.

Use Full (strict) when the origin listens on 443 and has a valid, unexpired certificate from a public CA or from Cloudflare Origin CA, for the correct hostname. If you do not have a public certificate, install a Cloudflare Origin CA certificate on the server, then switch the mode.

Avoid Flexible if you can. Flexible encrypts only the visitor-to-Cloudflare hop, so the origin can be spoken to over HTTP. That setup is a common source of redirect loops and mixed-content bugs on WordPress sites that already force HTTPS.

A 526 error after you choose Full (strict) means the origin certificate failed validation. Fix the certificate rather than dropping back to Flexible as a permanent workaround.

Do this if the origin already has a good certificate. Skip the SSL change until that certificate is in place, or you will take HTTPS down on purpose.

Step 3: Proxy the right DNS records

In DNS, an orange cloud means the record is proxied through Cloudflare. A grey cloud is DNS only, so traffic goes straight to the origin.

Proxy the website records, usually the apex and www A or CNAME records. Leave mail and most verification TXT records unproxied. If a hostname must talk to the origin on a non-web protocol, grey-cloud it.

Once those website records are proxied, static assets can be cached at the edge even before you buy APO.

That is already a useful WordPress CDN. Image files still benefit from a good optimizer, which is why an image optimization plugin and a CDN complement each other rather than replace each other.

Step 4: Install the official Cloudflare plugin

The official plugin is how Cloudflare expects you to connect WordPress, apply recommended settings, and (in the next step) switch on APO.

  1. In WordPress, go to Plugins → Add New, search for Cloudflare, and install the plugin by Cloudflare, Inc.
  2. Activate it, then open its Settings screen.
  3. In the Cloudflare dashboard, go to Account API tokens → Create Token, pick the WordPress template, and create the token.
  4. Back in WordPress, sign in with your Cloudflare email and paste the token. Save.
  5. When asked to apply recommended Cloudflare settings for WordPress, choose Apply.
Cloudflare APO documentation listing plan type, cache plugin compatibility and the multisite limitation
APO prerequisites, including plan type, cache-plugin compatibility and the multisite limitation. Source: developers.cloudflare.com, captured November 2026.

Store the token somewhere safe for a moment, then delete that copy once WordPress has accepted it. Do not drop API tokens into a ticket, a screenshot or a blog post.

The plugin page also asks for PHP 7.4 or higher. If you are still on an older PHP line, upgrade the runtime before you chase cache-header mysteries. Your hosting platform should make that switch obvious, and a staging check is still wise.

Step 5: Enable Automatic Platform Optimization

Per the APO activation docs, Free-plan users should purchase APO before relying on the plugin for this feature. On the dashboard that is Speed → Settings → Content Optimization → Automatic Platform Optimization for WordPress → Purchase. The WordPress.org listing prices the add-on at $5 per month on the Free plan, with unlimited subdomains.

On Pro or higher, APO is included. Cloudflare lists Pro at $25/month on its Pro plan page, checked November 2026. Confirm the current price at checkout before you upgrade just to get APO; the $5 add-on is cheaper if you do not need the rest of Pro.

Then, in the plugin settings, switch Automatic Platform Optimization to On.

⚠️ The catch: the APO WordPress plugin does not support multisite. Cloudflare also recommends turning off page-cache plugins such as WP Rocket or W3 Total Cache when you first enable APO, then testing them afterwards. Unexpected results are common when two layers both think they own the HTML.

After APO is on, clear any remaining origin or plugin caches so the first edge copies are clean.

Step 6: Verify the cache headers

Do not guess. The official verification page says APO is working when these headers are present on a cached HTML request:

  • CF-Cache-Status: HIT
  • cf-apo-via: tcache (the same page also shows a curl example with cf-apo-via: cache; either way, the header must be present)
  • cf-edge-cache: cache, platform=wordpress (this one confirms the plugin is in the mix)

In a terminal, Cloudflare’s documented command is:

curl -svo /dev/null -A "CF" 'https://example.com/' -H 'accept: text/html' 2>&1 | grep 'cf-cache-status\|cf-edge\|cf-apo-via'

Replace example.com with your domain and run the command twice, logged out.

Cloudflare documentation listing the CF-Cache-Status, cf-apo-via and cf-edge-cache headers used to verify APO
The three headers Cloudflare uses to confirm APO is serving cached HTML. Source: developers.cloudflare.com, captured November 2026.

The first request after a purge may be a MISS or DYNAMIC. Load the homepage twice, logged out, and look again. Then publish a small change in WordPress and confirm the page updates, which is how you know purge is wired up, not only caching.

If you only see CF-Cache-Status on images and CSS, you have a CDN, not APO. That is still useful. It is just not HTML at the edge.

Working with other cache plugins and WooCommerce

After APO is proven, you can try turning an origin cache plugin back on.

Test a logged-out page, a logged-in page, and a post update. If HTML becomes stale or login sessions act oddly, leave the origin HTML cache off and keep APO plus your host’s object or page cache only if it behaves.

Cloudflare’s APO compatibility notes list WooCommerce as compatible. APO bypasses HTML caching when WooCommerce cookies are present, and cart and checkout paths are excluded from that edge cache. Still avoid a blanket “Cache Everything” page rule that can override those bypasses.

On Elementor sites, treat this as one part of a wider speed pass. Our Elementor speed guide and INP fix guide cover the JavaScript and asset side that a CDN will not magically solve.

How to check it worked

  • The domain resolves through Cloudflare, and the dashboard shows the zone as active.
  • The front end loads over HTTPS with no certificate warning and no redirect loop.
  • /wp-admin/ and wp-login.php still work as they did before.
  • Logged-out homepage HTML shows the APO headers in Step 6, if you enabled APO.
  • A content edit appears on the front end after a refresh, without a manual purge, once the plugin is connected.
  • Email still flows, which means MX records were not accidentally proxied or dropped.

What breaks and how to undo it

SymptomLikely causeFix
Site or email down after the nameserver changeA missed DNS record, or MX left off the zoneCompare records with the host’s list and add the missing ones
Redirect loopFlexible SSL with WordPress forcing HTTPSInstall a valid origin certificate and use Full (strict)
Error 526Full (strict) cannot validate the origin certificateFix or replace the origin cert; do not stay on Flexible as the fix
APO headers missingAdd-on not purchased, plugin not connected, or first request after a purgeConfirm the plan and token, then request the page twice logged out
Stale HTML after an editPlugin not connected, or a second cache fighting APOReconnect the plugin; clear origin caches; pause the other HTML cache
Odd cart or login behaviorA Cache Everything rule, or another cache plugin ignoring cookiesRemove the blanket rule; rely on APO’s documented bypasses
Multisite will not use the APO pluginDocumented limitationDo not rely on the plugin for APO on multisite; use a different cache plan
Troubleshooting based on Cloudflare DNS, SSL and APO docs, checked November 2026.

To undo Cloudflare: switch the site’s records to DNS only (grey cloud) for a quick bypass, or change the nameservers back to your host or registrar and wait for propagation. Disable APO in the plugin first if you only want to drop HTML caching and keep the CDN.

Frequently Asked Questions

Is the free Cloudflare CDN enough for WordPress?

It is enough if you mainly want asset caching, DDoS protection and a proxy in front of the origin. The free plan does not, by itself, cache WordPress HTML at the edge. Add Automatic Platform Optimization when you want that HTML layer, then verify the APO headers on a logged-out page.

How much does Cloudflare APO cost?

On the Free plan, the official plugin listing prices APO at $5 per month, with unlimited subdomains. It is included with Pro and higher. Cloudflare listed Pro at $25 per month in November 2026. Confirm the figure at checkout, because plan pages change.

Can I use APO with WP Rocket or another cache plugin?

Cloudflare recommends turning those plugins off when you first enable APO, then testing them afterwards. Using APO with another HTML cache can cause stale or unexpected pages. Prove APO with the official headers first, then add an origin cache back only if tests still look clean.

How do I check if Cloudflare is caching my WordPress site?

Inspect response headers on a logged-out HTML request. A proxied site should show Cloudflare headers. APO is working when you also see CF-Cache-Status: HIT, cf-apo-via, and cf-edge-cache: cache, platform=wordpress, as documented on Cloudflare’s verification page.

Does Cloudflare APO work on WordPress multisite?

No. Cloudflare’s APO activation docs state that the APO WordPress plugin does not support multisite installations. You can still use Cloudflare as a CDN with a full DNS setup, but do not expect the plugin’s APO integration to be supported on a network of sites.

Will Cloudflare break my WordPress login or WooCommerce cart?

It should not if you use the official plugin and avoid a blanket Cache Everything rule. APO is documented as compatible with WooCommerce, bypassing cache when WooCommerce cookies are present and excluding cart and checkout. Always test login, cart and checkout after you enable it.

Do I have to change my nameservers?

For Free and Pro, yes. Those plans use a full setup, which means Cloudflare’s nameservers. Keeping your current DNS provider with a partial CNAME setup is documented as a Business or Enterprise feature. Review every DNS record, especially mail, before you switch.

Should I use Flexible, Full, or Full (strict) SSL?

Use Full (strict) when the origin has a valid certificate for the hostname, from a public CA or Cloudflare Origin CA. Flexible only encrypts the visitor hop and often causes redirect loops on WordPress sites that force HTTPS. A 526 error means the origin certificate failed validation.

Should you add Cloudflare, APO, or both?

Start with the free CDN if you can change nameservers and you want assets served from the edge. Get DNS and Full (strict) SSL right first. That alone is a solid WordPress CDN.

Add APO when you also want HTML cached at the edge. Pay $5 a month on Free, or use the copy included with Pro, and verify the three headers. Pause other HTML caches until that test passes.

Skip the plugin’s APO path on multisite, and skip a Free or Pro plan if you cannot move nameservers. In those cases, talk to the host about its own CDN, or budget for a Business-level setup if you need to keep your current DNS provider.

Last updated November 2026.

Lokesh Kapoor
Lokesh Kapoor

Lokesh Kapoor is a web developer, blogger, and digital creator passionate about WordPress, SaaS, automation, and modern web technologies. He shares practical tutorials, honest insights, and useful resources to help creators, entrepreneurs, and website owners build faster, smarter, and more effective online experiences with confidence, clarity, and consistency.

Articles: 46

Leave a Reply

Your email address will not be published. Required fields are marked *