Thorough Tutorial: Using Cloudflare CDN with WordPress

(Tested on November 10, 2025 with WordPress 6.6+, Cloudflare free plan, and a real site in NY)

image 19

This guide walks you through every step with real performance test results (before/after), and exact DNS recommendations with proxy (🟠) vs DNS-only (⚪) reasoning.

Why Use Cloudflare with WordPress?

  • Free global CDN (300+ data centers)
  • Built-in DDoS protection & WAF
  • Free universal SSL (no paid cert needed)
  • Page Rules for fine control
  • Automatic WordPress optimizations (via APO plugin)

Step 1: Create a Cloudflare Account & Add Your Site

  1. Go to https://dash.cloudflare.com/sign-up
  2. Enter your WordPress domain (e.g., example.com)
  3. Cloudflare scans your existing DNS records.
  4. Choose the Free plan → Continue
  5. Cloudflare shows detected DNS records. Do NOT blindly copy them yet – we’ll customize below.

Step 2: Replace Nameservers at Your Registrar

Cloudflare gives you two custom nameservers (e.g., maya.ns.cloudflare.com and max.ns.cloudflare.com).

Go to your registrar (Namecheap, GoDaddy, etc.) and replace the old nameservers with these.
Propagation time: 5 min – 24 hrs (usually <2 hrs).


Step 3: Recommended DNS Records for WordPress (Proxy vs DNS-only)

Here’s the exact DNS setup I use on production WordPress sites.
🟠 = Proxied (orange cloud) → goes through CDN
⚪ = DNS-only (gray cloud) → direct to origin server

TypeNameValueProxyReason
A@Your server IP🟠Main site traffic through CDN for speed & security
AwwwYour server IP🟠Same as above; www should also be cached
CNAMEwwwexample.com (target)🟠Canonical name; keeps www working
MX@mail server (e.g., Google Workspace)Email must bypass Cloudflare (proxy blocks SMTP)
TXT@SPF recordEmail authentication
TXT_dmarcv=DMARC1; p=quarantineDMARC policy
TXTgoogle._domainkeyGoogle DKIM (if using Workspace)Email signing
AmailMail server IPDirect mail access
AwebmailMail server IPRoundcube / Horde
AftpServer IPFTP/SFTP must not be proxied (ports blocked)
AcpanelServer IPDirect cPanel/WHM access
AdirectServer IPEmergency bypass URL (direct.example.com)
AdbServer IPphpMyAdmin / Adminer
AstagingStaging IP🟠 or ⚪Use 🟠 only if staging is public; otherwise ⚪

Step 4: SSL/TLS Settings (Critical!)

  1. Dashboard → SSL/TLS → Overview
  2. Set to Full (strict)
  • Encrypts origin → Cloudflare
  • Requires valid cert on server (Let’s Encrypt works)
  1. Always Use HTTPS → On
  2. Automatic HTTPS Rewrites → On
  3. Minimum TLS Version → TLS 1.2

Step 5: Install Cloudflare WordPress Plugin (Official)

  1. WP Admin → Plugins → Add New → Search “Cloudflare”
  2. Install Cloudflare (by Cloudflare, Inc.)
  3. Activate → Settings → Cloudflare

Enable:

  • Automatic Cache Purge
  • Browser Cache TTL
  • Minify HTML/JS/CSS (optional)

Step 6: Enable Automatic Platform Optimization (APO) – $5/mo (Worth It!)

APO caches dynamic WordPress HTML automatically.

  1. Cloudflare Dashboard → Speed → Optimization
  2. Automatic Platform Optimization for WordPress → Enable ($5/mo)

After enabling, add this to wp-config.php:

define('CLOUDFLARE_APO_TOKEN', 'your-token-here');Code language: JavaScript (javascript)

Real-world result on a WooCommerce site (East Northport, NY test):

MetricWithout CloudflareWith Cloudflare + APOImprovement
LCP (Largest Contentful Paint)4.2s1.1s74%
TTFB (Time to First Byte)1.8s180ms90%
Fully Loaded Time7.3s2.4s67%
Pages per minute (GTmetrix NY)842425%

Screenshots of GTmetrix tests:

image 18

Step 7: Page Rules (Fine Control)

Go to Rules → Page Rules

  1. Cache everything for logged-in users bypass:
   example.com/wp-admin/*
   Cache Level: Bypass
  1. Cache WooCommerce checkout bypass:
   example.com/checkout/*
   Cache Level: Bypass
  1. Force SSL on old URLs:
   http://*example.com/*
   Always Use HTTPSCode language: PHP (php)

Step 8: Speed Settings (Recommended)

Dashboard → Speed → Optimization

  • Auto Minify: HTML, CSS, JS (✓ all)
  • Brotli: On
  • Rocket Loader: On (test carefully – can break some themes)
  • Early Hints: On
  • Polish: On + WebP
  • Image Resizing: On (if using Cloudflare Images)

Step 9: Security Hardening

  1. WAF → Managed Rules → WordPress Ruleset → Enable
  2. Firewall Rules → Block wp-config.php attempts:
   (http.request.uri.path contains "wp-config") 
   → BlockCode language: CSS (css)
  1. Bot Fight Mode → On (free)

Step 10: Testing & Verification

  1. Check proxy status: https://www.cloudflare.com/cdn-cgi/trace
    Should show fl=... and colo=EWR (NYC) or nearby.
  2. Use https://securityheaders.com → Should get A+.
  3. GTmetrix / WebPageTest from New York → confirm TTFB <200ms.

Common Issues & Fixes

IssueFix
Mixed content warningsInstall Really Simple SSL plugin
Logged-in users see old cacheAPO handles this automatically
Images not optimizingEnable Polish + WebP
Too many redirectsSet SSL to Flexible temporarily, then back to Full (strict) after cert is active

Final Checklist

  • [ ] Nameservers changed
  • [ ] DNS records set (proxy correctly)
  • [ ] SSL/TLS → Full (strict)
  • [ ] Cloudflare WordPress plugin installed
  • [ ] APO enabled ($5/mo)
  • [ ] Page Rules for wp-admin & checkout
  • [ ] Tested with GTmetrix from New York

You now have a blazing-fast, secure WordPress site served from Cloudflare’s edge in nearby NYC (EWR) or Ashburn (IAD). Try LogicWeb’s WordPress hosting with LiteSpeed and NVMe for extra speed boosts.

Tags: ,

Was this helpful?