How to Set Up a CDN for WordPress (Step by Step)

How to Set Up a CDN for WordPress (Step by Step)

A Content Delivery Network (CDN) serves your site’s static files — images, CSS, JavaScript, and fonts — from servers geographically close to your visitors. Setting up a CDN for WordPress typically takes 15–30 minutes and can reduce page load times by 40–60% for visitors who are far from your hosting server. The easiest option is Cloudflare, which offers a free tier with generous limits and can be set up in under 15 minutes.

Without a CDN, every asset on your page is served from your single hosting server — which might be in New York, London, or Singapore. A visitor in Australia loading your US-hosted site experiences 200–400 milliseconds of network latency on every single request. With a CDN, those assets are cached on edge servers worldwide, so the same Australian visitor loads them from a server in Sydney with just 10–30 milliseconds of latency. Multiply that saving across 30–80 requests per page load and the total improvement is dramatic.

For context on how CDN setup fits into a complete speed optimization strategy, read our comprehensive WordPress speed guide.

What a CDN Does (and Does Not Do)

What a CDN Caches

A CDN caches and serves static content: images (JPEG, PNG, WebP, GIF, SVG), CSS stylesheets, JavaScript files, web fonts (WOFF, WOFF2, TTF), and other static assets like PDFs and downloadable files. These files rarely change, so caching them on globally distributed servers is safe and effective.

What a CDN Does Not Replace

A CDN does not replace page caching. Page caching (handled by plugins like WP Rocket or LiteSpeed Cache — see our caching plugin comparison) stores the fully rendered HTML of your pages. A CDN distributes static files geographically. These are complementary optimizations — you should use both for maximum performance.

A CDN also does not fix slow server response times (TTFB). If your hosting server takes 2 seconds to generate a page, the CDN will serve static assets faster but the initial HTML response still takes 2 seconds. For server-level performance issues, see our guide on reducing TTFB.

Option 1: Cloudflare (Recommended Free Option)

Cloudflare is the most popular CDN for WordPress. Their free tier includes global CDN caching, DNS hosting, basic DDoS protection, SSL certificate, and web analytics. For most WordPress sites, the free tier is more than sufficient.

Step 1: Create a Cloudflare Account

Go to cloudflare.com and sign up for a free account. Add your domain name. Cloudflare will scan your existing DNS records.

Step 2: Verify DNS Records

Cloudflare imports your existing DNS records automatically. Review them carefully. Ensure your A record (pointing to your hosting server’s IP address), any CNAME records, MX records (for email), and TXT records (for verification and SPF) are all correct. If any records are missing, add them manually. Getting DNS records wrong can break your email or make your site unreachable — review carefully.

Step 3: Change Your Nameservers

Cloudflare will give you two nameservers to use (e.g., ann.ns.cloudflare.com and bob.ns.cloudflare.com). Log in to your domain registrar (wherever you bought your domain — GoDaddy, Namecheap, Google Domains, etc.) and update your nameservers to the ones Cloudflare provided. This change can take up to 24 hours to propagate, though it often happens within a few hours.

Step 4: Configure Cloudflare Settings

Once your nameservers propagate and Cloudflare confirms your domain is active, configure these settings. Under SSL/TLS, set the encryption mode to “Full (Strict)” — this ensures encrypted connections between visitors, Cloudflare, and your server. Under Caching, set the caching level to “Standard.” Under Speed, enable auto-minification for JavaScript, CSS, and HTML. Enable Brotli compression.

Step 5: Install a WordPress Plugin (Optional)

Install the official Cloudflare plugin for WordPress. It automatically purges the Cloudflare cache when you publish or update content, applies WordPress-optimised settings, and provides a Cloudflare dashboard widget in your WordPress admin. Alternatively, if you use WP Rocket, it has built-in Cloudflare integration — no separate plugin needed.

WooCommerce-Specific Cloudflare Settings

If you run a WooCommerce store, create a Page Rule to bypass caching for your cart and checkout pages. Go to Rules → Page Rules → Create Page Rule. Set the URL pattern to *yourdomain.com/cart/* and set “Cache Level” to “Bypass.” Create another rule for *yourdomain.com/checkout/*. This prevents Cloudflare from caching user-specific WooCommerce pages. For more WooCommerce-specific performance tips, see our WooCommerce speed guide.

Option 2: BunnyCDN (Best Budget Premium CDN)

BunnyCDN is a pay-as-you-go CDN with pricing starting at $0.01 per GB of bandwidth — making it one of the most affordable premium CDNs available. For a typical WordPress site serving 10–50 GB of CDN traffic per month, the cost is $0.10–$0.50 per month. It also offers BunnyOptimize for automatic image optimization and WebP conversion.

Setup Process

Create a BunnyCDN account at bunny.net. Create a new Pull Zone — this is BunnyCDN’s term for a CDN configuration. Enter your site’s URL as the origin. BunnyCDN will provide you with a CDN hostname (e.g., yoursite.b-cdn.net). In your WordPress site, configure your caching plugin or a CDN enabler plugin (like CDN Enabler by KeyCDN) to rewrite static asset URLs to your BunnyCDN hostname. BunnyCDN also supports custom CDN domains with SSL (e.g., cdn.yourdomain.com).

When to Choose BunnyCDN Over Cloudflare

BunnyCDN is a pure CDN — it does not require changing your nameservers or routing all your traffic through a proxy. If you want CDN benefits without changing your DNS hosting, or if you need more control over CDN caching behaviour, BunnyCDN is the better choice. Cloudflare’s free tier is more feature-rich (includes DNS, DDoS protection, and WAF), but BunnyCDN’s per-GB pricing can be cheaper for high-traffic sites.

Option 3: Your Hosting Provider’s Built-In CDN

Many managed WordPress hosting providers include a CDN as part of their hosting package. Cloudways includes Cloudflare Enterprise (significantly better than the free tier). Kinsta includes a built-in CDN powered by Cloudflare. SiteGround includes its own SG CDN. WP Engine includes its proprietary CDN.

If your host includes a CDN, enable it through your hosting dashboard. Using your host’s built-in CDN is usually the simplest option because it is pre-configured for your server environment and does not require DNS changes or third-party account setup. Check your hosting documentation for activation instructions.

How to Verify Your CDN Is Working

After setup, verify the CDN is actually serving your static files. Open your site in Chrome. Press F12 to open Developer Tools. Click the Network tab. Reload the page. Click on any static asset (an image, a CSS file, a JS file). In the Response Headers, look for headers that indicate CDN delivery — for Cloudflare, you will see cf-cache-status: HIT (meaning the asset was served from Cloudflare’s cache). For BunnyCDN, you will see CDN-Cache: HIT.

Also test your site speed from a location far from your hosting server. Use GTmetrix (gtmetrix.com) and select a test location in a different continent from your server. Compare the results to a test from a location near your server. The difference in load times demonstrates the CDN’s impact.

Common CDN Configuration Mistakes

Caching dynamic WooCommerce pages. Cart, checkout, and account pages must be excluded from CDN page caching. Failing to exclude them causes customers to see other users’ cart contents or cached checkout states.

Not purging cache after content updates. If you update a CSS file, publish a new blog post, or change an image, the CDN may continue serving the old cached version. Use your CDN’s purge feature or configure automatic cache invalidation through your WordPress plugin.

Mixed content after CDN setup. If your CDN serves assets over HTTP while your site uses HTTPS (or vice versa), browsers will display mixed content warnings. Ensure your CDN is configured to serve all assets over HTTPS.

Caching admin pages. WordPress admin pages should never be cached. Most CDNs and caching plugins automatically exclude /wp-admin/ and /wp-login.php, but verify this in your configuration.

Frequently Asked Questions

Do I need a CDN if my audience is in one country?

Even within a single country, a CDN provides benefits. CDN edge servers reduce the load on your origin server, improve reliability during traffic spikes, and can serve assets faster than your hosting server alone. The benefits are smaller than for a global audience, but they are still measurable — typically 10–20% improvement even for domestic traffic.

Will a CDN help with Google Core Web Vitals?

Yes. A CDN primarily improves Largest Contentful Paint (LCP) by delivering images and fonts faster. It also reduces Time to First Byte (TTFB) for cached resources. These improvements directly contribute to better Core Web Vitals scores and, consequently, better search rankings. Read our guide on improving Core Web Vitals.

Can I use a CDN with any hosting provider?

Yes. CDNs work with any hosting provider — shared, VPS, dedicated, or managed. Cloudflare requires changing your nameservers (which works with any host). BunnyCDN and similar pull-zone CDNs work by rewriting asset URLs (which also works with any host).

Is Cloudflare’s free tier really enough?

For most WordPress sites, yes. Cloudflare’s free tier includes unlimited CDN bandwidth, DNS hosting, basic DDoS protection, and a shared SSL certificate. You only need to upgrade to a paid plan if you need advanced features like image optimization (Polish), advanced firewall rules (WAF), or guaranteed uptime SLAs.

Need Expert Help? Let WP Ministry Handle It

CDN setup is straightforward but getting the configuration right — especially for WooCommerce stores and sites with complex caching requirements — matters. Our speed optimization service, included in Pro care plans and above, includes CDN setup and configuration as part of a comprehensive performance optimization.

View our care plans → or call (901) 249-0909.

Related Articles

How to Speed Up Your WordPress Site (Complete 2026 Guide)

Best WordPress Caching Plugins Compared (2026)

How to Optimise WordPress Images Without Losing Quality

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment