If your WordPress server is in New York and a visitor loads your site from Tokyo, every asset travels 13,000 km each way. With a CDN, the same assets are served from a Tokyo edge node — milliseconds instead of hundreds of milliseconds. For sites with international traffic, a CDN is the single highest-ROI performance investment available.
How a CDN works
A CDN is a network of servers ("edge nodes" or "PoPs" — Points of Presence) distributed around the world. When a visitor requests an asset (image, CSS, JS file), their request is routed to the nearest edge node. If that node has the file cached, it serves it immediately. If not, it fetches it from your origin server, caches it, and serves it — subsequent requests for the same file are served from the cache.
For WordPress, a CDN handles:
- Images (
/wp-content/uploads/) - CSS and JavaScript files (
/wp-content/themes/,/wp-content/plugins/) - Core WordPress files (
/wp-includes/) - Optionally: full HTML page caching at the edge (faster but requires configuration)
CDN options compared
| CDN | Price | PoPs | Best for |
|---|---|---|---|
| Cloudflare | Free–$20/mo | 310+ | Most sites — free tier is excellent |
| BunnyCDN | $0.01/GB | 117+ | Budget-conscious, high traffic |
| KeyCDN | $0.04/GB | 57+ | Mid-size sites, simple setup |
| Cloudinary | Free–$99/mo | Global | Image-heavy sites, automatic optimization |
| Amazon CloudFront | Pay-per-use | 450+ | Enterprise, AWS ecosystem |
Option 1: Cloudflare (recommended for most sites)
Cloudflare is the easiest CDN to set up for WordPress and the free tier is genuinely excellent. It works as a reverse proxy — all traffic passes through Cloudflare, which adds caching, DDoS protection, and performance features.
Setup steps:
- Create a Cloudflare account at cloudflare.com and click "Add a Site"
- Enter your domain and select the free plan
- Cloudflare scans your DNS records — verify they're all imported correctly
- Update your nameservers at your domain registrar to Cloudflare's nameservers (shown in the setup wizard). DNS propagation takes 24–48 hours.
- Enable SSL/TLS → set to "Full (Strict)" if your origin has a valid SSL certificate
- Enable caching → Caching → Configuration → Caching Level: Standard
Recommended Cloudflare settings for WordPress:
- Speed → Optimization: Enable Auto Minify (HTML, CSS, JS), enable Rocket Loader (test thoroughly — can break some JS)
- Caching → Browser Cache TTL: 1 year (for versioned assets)
- Security → Security Level: Medium
- SSL → Always Use HTTPS: On
WordPress + Cloudflare plugin:
Install the official Cloudflare plugin for WordPress. It allows you to purge the Cloudflare cache from the WordPress admin and automatically purges when you publish or update content. This is essential — without it, changes to your site may not appear to visitors immediately.
wp-admin bypass: Cloudflare should never cache your admin area. It doesn't by default, but verify by adding a Page Rule: *yourdomain.com/wp-admin/* → Cache Level: Bypass.
Option 2: BunnyCDN (best value)
BunnyCDN charges $0.01/GB for bandwidth (with a $1/month minimum) — making it one of the most cost-effective CDNs available. Unlike Cloudflare, it's a "pull CDN" — you configure it with your origin URL and it pulls and caches your assets on first request.
Setup steps:
- Create account at bunny.net and add a new Pull Zone
- Set your Origin URL to your WordPress site (e.g.,
https://yoursite.com) - Note your Pull Zone URL (e.g.,
yoursite-cdn.b-cdn.net) - Optionally: add a custom CDN hostname like
cdn.yoursite.comvia CNAME record - In WordPress, install CDN Enabler or configure your caching plugin's CDN settings
- Set the CDN URL to your BunnyCDN pull zone URL
WordPress CDN URL rewriting:
Most caching plugins (WP Rocket, W3 Total Cache, LiteSpeed Cache) have a built-in CDN settings section. Enter your CDN URL and the plugin automatically rewrites asset URLs in the HTML to point to the CDN instead of your origin.
// Manual CDN URL rewriting (if not using a plugin)
add_filter('wp_get_attachment_url', function($url) {
return str_replace(
'https://yoursite.com',
'https://cdn.yoursite.com',
$url
);
});
Option 3: KeyCDN
KeyCDN is a straightforward pull CDN at $0.04/GB. Setup is similar to BunnyCDN — create a pull zone, configure your origin, and rewrite asset URLs in WordPress. It's reliable with good documentation and a simple interface.
KeyCDN provides a free WordPress plugin (CDN Enabler) that they officially maintain, making WordPress integration straightforward.
How much does a CDN actually help?
Real-world improvements depend heavily on where your visitors are located relative to your origin server. Typical results:
| Visitor location vs server | Without CDN | With CDN | Improvement |
|---|---|---|---|
| Same country as server | 300ms | 250ms | ~15% |
| Same continent, different country | 600ms | 300ms | ~50% |
| Different continent | 1200ms | 350ms | ~70% |
If most of your visitors are local, a CDN helps but isn't transformative. If you have global traffic, it's essential.
What a CDN does NOT solve
A CDN accelerates static asset delivery but doesn't fix:
- High TTFB — the HTML document itself must still be generated by your server (unless you cache full pages at the edge)
- Slow WordPress database queries — these happen before the CDN is involved
- Poor mobile performance — mobile PageSpeed issues are often about JS execution, not transfer time
- Render-blocking resources — CDN serves them faster, but they still block rendering
Full HTML caching at the edge (advanced)
For maximum performance, you can cache your WordPress HTML pages at the CDN edge — bypassing your origin server entirely for cached pages. This requires:
- Cloudflare Pro ($20/mo) with Cache Rules, or the free "Cache Everything" Page Rule
- Careful bypass rules for: wp-admin, logged-in users, WooCommerce cart/checkout, nonces
- Cache purging on content updates
With this setup, cached pages achieve sub-30ms TTFB globally — comparable to a static site.
WPStats tip: After setting up your CDN, run WPStats on your site again. You'll see improvements in your PageSpeed scores, especially LCP and overall performance. WPStats also detects Cloudflare in the Features section.
Check if your WordPress site has a CDN
WPStats detects Cloudflare and shows your real PageSpeed scores. See where your site stands in seconds.
Analyze my site now