All Guides
Technical Performance

CDN Setup Guide

Serve your site from edge servers worldwide.

What this covers: What a CDN does, which provider to choose (Cloudflare for most sites), step-by-step Cloudflare setup including nameserver changes and caching configuration, and how to verify it’s working.

Who it’s for: Site owners who want faster global load times and better uptime, especially if their audience spans multiple regions.

Key outcome: You’ll have Cloudflare (or equivalent CDN) fully configured — serving static assets from edge servers worldwide, with auto-minification, Brotli compression, and HTTP/3 enabled.

Time to read: 4 minutes

Part of: Technical Performance series

A CDN puts copies of your static files (images, CSS, JavaScript) on servers around the world. When someone visits your site, they get files from the nearest server instead of your origin. Result: faster load times, less load on your server, and better uptime if your origin goes down.

Which CDN to Choose

For most sites, Cloudflare is the answer. The free tier includes unlimited bandwidth, DDoS protection, and a global network. You only need a paid CDN if you have specific requirements like real-time cache purging (Fastly) or deep AWS integration (CloudFront).

CDN Best For Free Tier
Cloudflare Most sites Unlimited bandwidth
Fastly Real-time purging needs $50/month credit
CloudFront AWS-heavy stacks 1TB/month (first year)
Bunny CDN Budget option 14-day trial

Set Up Cloudflare (30 minutes)

Cloudflare works by becoming your DNS provider. All traffic flows through their network, where they can cache content and block attacks. Setup is straightforward but requires changing your nameservers—so do this during low-traffic hours.

1. Create Account and Add Site

Sign up at cloudflare.com and add your domain. Cloudflare will scan your existing DNS records automatically.

2. Update Your Nameservers

Cloudflare gives you two nameservers to use:

ns1.cloudflare.com
ns2.cloudflare.com

Go to your domain registrar (GoDaddy, Namecheap, wherever you bought the domain) and replace the existing nameservers with these. Propagation takes up to 24 hours, but usually faster.

3. Configure Caching

In Cloudflare dashboard, go to Caching → Configuration:

  • Set “Browser Cache TTL” to at least 4 hours
  • Enable “Always Online” so Cloudflare serves a cached version if your origin goes down

4. Enable Performance Features

These are free and make a measurable difference:

  • Auto Minify (Speed → Optimization) – Removes whitespace from JS/CSS/HTML
  • Brotli (Speed → Optimization) – Better compression than gzip
  • HTTP/3 (Network) – Faster protocol for modern browsers

Verify It’s Working

After nameservers propagate, check if Cloudflare is serving your content:

curl -I https://yoursite.com

Look for these headers:

cf-cache-status: HIT
server: cloudflare

HIT means content came from CDN cache. MISS means it went to your origin (first request, or uncached content). BYPASS means caching is disabled for that resource.

What to Cache (and What Not To)

Cache static, public content. Don’t cache dynamic, user-specific content.

Cache aggressively:

  • Images, CSS, JavaScript files
  • Public pages (homepage, blog posts, product pages)
  • Media files (PDFs, videos, downloads)

Don’t cache:

  • Admin areas (/wp-admin/*)
  • User-specific content (shopping carts, account pages)
  • API responses with personal data

Cloudflare automatically handles most of this, but you can fine-tune with Page Rules if needed.

Confirming Your CDN Is Serving Assets

  • CDN is serving your static assets (check response headers for CDN name)
  • TTFB has improved for users far from your server
  • SSL is working through the CDN (no mixed content warnings)
  • Cache hit ratio is above 80% (check CDN dashboard)

Sources

CDN Setup Questions Answered

What is a CDN and why do I need one?

A Content Delivery Network stores copies of your site”s static files (images, CSS, JavaScript) on servers worldwide. When someone visits your site, files load from the nearest server instead of your origin server. This reduces load times by 40-60% for distant visitors.

Is Cloudflare”s free CDN good enough?

For most small-to-medium sites, yes. Cloudflare”s free tier includes global CDN, DDoS protection, free SSL, and basic caching. Paid tiers add image optimization, advanced caching rules, and WAF. Upgrade when you need Polish (image optimization) or Argo (smart routing).

Will a CDN break my WordPress site?

It can if misconfigured. Common issues: cached login pages showing other users” data, WooCommerce cart caching, and CSS/JS not updating after changes. Always exclude dynamic pages (wp-admin, cart, checkout, my-account) from caching. Most WordPress CDN plugins handle this automatically.

How do I know if my CDN is working?

Check HTTP response headers for your CDN”s cache indicator. For Cloudflare: look for cf-cache-status: HIT. For other CDNs, check for X-Cache: HIT or similar headers. Use your browser”s DevTools Network tab or a tool like GTmetrix to inspect response headers.

✓ Your CDN Is Properly Configured When

  • Response headers show your CDN (cf-cache-status, x-cache, or equivalent) returning HIT on static assets
  • Assets load from CDN edge locations — verify with curl -I that the server header shows the CDN, not your origin
  • SSL works end-to-end with no mixed content warnings in the browser console
  • Cache purge works: after purging, first request shows MISS, second request shows HIT
  • TTFB from a distant geographic region drops by at least 40% compared to pre-CDN baseline

Test it: Run curl -I https://yoursite.com/wp-content/themes/your-theme/style.css and confirm the cache status header shows HIT and the server header shows your CDN provider.