WordPress CDN Setup: How to Speed Up Your Site with a Content Delivery Network
Learn what a CDN does, how to set one up on WordPress, and which configuration options make the biggest difference for load times and Core Web Vitals scores.
Want the fastest WordPress hosting?
Rocket.net delivers 83ms average TTFB - up to 153% faster than competitors. Try it risk-free.
A content delivery network (CDN) is one of the highest-impact changes you can make to a WordPress site’s performance. For many sites, enabling a CDN cuts load times by 30–60% for visitors outside the server’s geographic region — and it does so without touching a single line of application code.
This guide explains what a CDN does, how to integrate one with WordPress, and what to configure to get the most out of it.
What a CDN Actually Does
When someone visits your WordPress site, their browser downloads HTML, CSS, JavaScript, images, and fonts from your origin server. If your server is in Dallas and your visitor is in London, every asset has to travel thousands of miles — adding latency on every request.
A CDN solves this by caching copies of your static assets at edge nodes distributed globally. A London visitor receives cached files from a CDN node in Frankfurt, not from Dallas. The round-trip is measured in single-digit milliseconds instead of 100+ms.
Beyond latency, CDNs offer:
- Reduced origin server load — edge nodes absorb the bulk of asset requests, so your server spends less time serving static files and more capacity goes to PHP/database work.
- Automatic compression — most CDNs apply gzip or Brotli compression to text assets.
- DDoS mitigation — CDN capacity absorbs traffic spikes and volumetric attacks that would otherwise overwhelm a shared or VPS host.
- HTTP/2 and HTTP/3 delivery — edge nodes typically support the latest protocols even if your origin server doesn’t.
What Gets Cached on a CDN
CDNs are most effective for static assets — files that don’t change per visitor:
- Images (
.jpg,.png,.webp,.svg,.gif) - CSS files
- JavaScript files
- Web fonts (
.woff2,.woff) - Video files and downloadable PDFs
HTML pages can be cached at the CDN layer, but this requires careful configuration because WordPress generates dynamic content (logged-in users, WooCommerce carts, etc.). Most setups cache HTML for anonymous visitors only, or skip HTML caching entirely and rely on a server-side page cache instead.
CDN Options for WordPress
Cloudflare (Free tier available)
Cloudflare operates as a reverse proxy CDN — your domain’s DNS points to Cloudflare, and all traffic passes through their network before reaching your origin. The free tier includes:
- Global CDN for static assets
- Basic DDoS protection
- SSL/TLS termination
- Minification of HTML, CSS, and JS
The free plan does not cache HTML by default. You can add page rules or cache rules to cache static pages, but this requires careful exclusion of admin, cart, and account pages.
BunnyCDN and KeyCDN (Pull CDN)
Pull CDNs work differently: you create a CDN “zone” that mirrors your origin, then rewrite your asset URLs to point to the CDN domain (e.g., cdn.yourdomain.com). Assets are fetched from origin on first request, then cached at the edge.
BunnyCDN is known for competitive pricing and a large edge network. KeyCDN offers similar capability with a straightforward pay-per-GB model. Both require a WordPress plugin (or manual URL rewriting) to change asset URLs.
CDN Built Into Your Hosting
Some managed WordPress hosts bundle a CDN directly into their hosting product. This is often the simplest option because there’s no separate account or DNS change required — the CDN is configured at the infrastructure level and assets are automatically distributed.
Setting Up a CDN on WordPress: Step-by-Step
Option A: Cloudflare (Reverse Proxy)
- Create a Cloudflare account and add your domain.
- Update your domain’s nameservers to point to Cloudflare’s nameservers (provided during setup). This routes all traffic through Cloudflare.
- Set SSL mode to “Full (strict)” under SSL/TLS settings. This encrypts traffic between Cloudflare and your origin server. Do not leave it on “Flexible” if your origin has a valid certificate.
- Enable Auto Minify (Speed → Optimization) for CSS and JS if you’re not already minifying on the server.
- Check caching behavior under Caching → Configuration. The default “Standard” caching level works for most sites.
- Exclude admin and dynamic pages from caching by adding a Page Rule or Cache Rule for
yourdomain.com/wp-admin/*with Cache Level = Bypass.
After propagation (usually under an hour), check asset delivery with your browser’s developer tools — static assets should show a cf-cache-status: HIT response header on repeat visits.
Option B: Pull CDN (BunnyCDN / KeyCDN)
- Create a CDN zone in your provider’s dashboard. Point it at your origin domain (e.g.,
yourdomain.com). - Note your CDN hostname (e.g.,
yourdomain-com.b-cdn.netfor BunnyCDN). - Optionally set up a custom CDN subdomain (e.g.,
cdn.yourdomain.com) via a CNAME record in your DNS. - Install a CDN plugin in WordPress. CDN Enabler and WP Rocket both support CDN URL rewriting. In WP Rocket, enter your CDN hostname under Settings → CDN.
- Test: Load your site, inspect source HTML, and confirm static asset URLs now point to the CDN domain.
- Purge the CDN cache after deploying updates to CSS or JS files.
Cache-Control Headers: Why They Matter
CDN behavior depends heavily on the Cache-Control headers your origin server sends. If your server sends Cache-Control: no-store or a very short max-age, the CDN may not cache the asset at all, or may re-validate it on every request.
For static assets with versioned filenames (e.g., style.min.css?ver=6.4.2), you want long cache lifetimes:
Cache-Control: public, max-age=31536000, immutable
WordPress’s built-in asset loader appends query strings for cache busting. Most CDNs respect query strings by default, meaning a new ?ver= value results in a fresh cache fetch.
If you’re using Nginx, you can set cache headers for static asset types directly:
location ~* \.(js|css|png|jpg|jpeg|gif|webp|svg|ico|woff2|woff)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
CDN and WordPress Admin: What to Exclude
CDN caching should never apply to:
/wp-admin/*— the admin dashboard must always be served dynamically./wp-login.php— caching the login page can cause nonce mismatches.- Cart and checkout pages (WooCommerce:
/cart/,/checkout/,/my-account/) - Any URL with
?query strings that return personalized content - REST API endpoints (
/wp-json/*) if they return user-specific data
Most CDN providers let you set bypass rules by URL path or response cookie. For Cloudflare, you can create a Cache Rule that bypasses cache when the woocommerce_cart_hash, woocommerce_session, or wordpress_logged_in_* cookies are present.
Measuring CDN Impact
Before enabling a CDN, record baseline metrics:
- Google PageSpeed Insights — note LCP, FID/INP, and CLS scores for a page with heavy image/script content.
- WebPageTest — run tests from multiple geographic locations. Compare load times from a location far from your origin server.
- Time to First Byte (TTFB) — CDNs reduce asset delivery time but have limited effect on TTFB for uncached HTML (that still hits your origin).
After enabling the CDN, re-run the same tests. You should see improvement in total page size delivered (if compression is enabled), reduced asset load times on repeat visits (cache hits), and faster loads for geographically distant visitors.
CDN Limitations to Know
A CDN is not a substitute for a fast origin server. If your WordPress site has slow PHP execution, heavy database queries, or no page cache, TTFB will remain high regardless of CDN configuration. A CDN accelerates delivery of assets, but the initial HTML document still comes from your server.
Similarly, a CDN won’t fix:
- Render-blocking scripts that delay page rendering
- Unoptimized images (the CDN delivers large images faster, but optimizing them first is better)
- Slow server response times caused by unoptimized plugins or insufficient server resources
For the best results, combine a CDN with server-side page caching and a host that provides fast PHP execution.
The Hosting Layer Matters
When choosing a CDN, it’s worth noting that the quality of your hosting directly affects what the CDN can do for you. A CDN can deliver cached assets quickly, but the origin server still handles cache misses, logged-in traffic, and all dynamic requests.
Rocket.net is a managed WordPress hosting provider that includes a built-in CDN powered by Cloudflare’s enterprise network, along with server-side caching configured out of the box. Rather than setting up a separate CDN account and configuring cache rules manually, the CDN is part of the hosting infrastructure and preconfigured for WordPress.
For sites where performance is a priority and you’d rather not spend time on CDN configuration, a managed host that includes CDN as part of the product is worth evaluating. You can learn more about Rocket.net’s hosting plans here.
Summary
A CDN is one of the most effective and straightforward performance improvements available for WordPress sites. The core steps are:
- Choose a CDN approach: reverse proxy (Cloudflare) or pull CDN (BunnyCDN, KeyCDN).
- Configure DNS or asset URL rewriting as required.
- Exclude dynamic pages, admin, and authenticated sessions from caching.
- Verify cache headers and test from geographically distributed locations.
For most WordPress sites, enabling a CDN alongside a page cache will deliver the majority of achievable performance gains — often without modifying any application code.
Performance tip: Your hosting provider has a bigger impact on WordPress speed than any plugin or optimization. We've tested dozens of hosts - Rocket.net consistently delivers the best results.
View Rocket.net Pricing →Ready to switch to faster WordPress hosting?
Join thousands who've made the switch to Rocket.net. Try any plan for just $1.
Start Your $1 Trial30-day money-back guarantee • Free migrations • No contracts
Related Articles
10 Best WordPress Caching Plugins for 2026 (Speed Test Results)
Comprehensive testing of the top WordPress caching plugins. Real performance data, pros/cons, and our honest recommendations for faster loading times.
How to Reduce Time to First Byte (TTFB) in WordPress
TTFB is one of the most impactful performance metrics for WordPress sites. Learn what causes slow TTFB and the most effective ways to fix it.
WordPress Image Optimization: A Complete Guide to Faster Load Times
Images are often the largest assets on a WordPress page. Learn how to compress, resize, convert to modern formats, and deliver images efficiently to dramatically improve page speed.