Short answer: To configure a CDN for WordPress, first sign up with a CDN provider (like Cloudflare or KeyCDN). Then install a CDN plugin (e.g., CDN Enabler) or use the provider’s plugin. Next, enter your CDN URL in the plugin settings, configure caching rules, and ensure SSL is enabled. Finally, test your site using browser tools or PageSpeed Insights to confirm assets are loading from the CDN.
Key takeaways
- Choose a CDN provider that integrates well with WordPress.
- Use a CDN plugin or host-level integration to simplify setup.
- Proper caching rules prevent serving stale content.
- Always enable SSL between CDN and origin for security.
- Test with real browser tools, not just online checkers.
- Monitor CDN logs to catch misconfigured assets.
What you will find here
A CDN—Content Delivery Network—sits between your visitors and your server, caching static files like images, CSS, and JavaScript on servers around the world. For WordPress, a properly configured CDN can cut load times significantly, especially for visitors far from your host. But setup isn’t just about flipping a switch. You need to pick the right provider, install the right plugin, and tweak caching rules so nothing breaks. Here’s how to do it step by step.

Step 1: Choose a CDN Provider
Not all CDNs are created equal for WordPress. Some, like Cloudflare, offer a free tier and deep WordPress integration through their own plugin. Others, like Bunny CDN or KeyCDN, are pay-as-you-go and work well with generic CDN plugins. Your choice depends on budget, technical comfort, and features you need.
If you want simplicity, start with Cloudflare. It handles DNS, CDN, and security in one dashboard. For more control over origin pull zones, Bunny CDN is fast and affordable. KeyCDN also offers a straightforward pull zone setup.
Quick comparison:
| Provider | Free Tier | WordPress Plugin | Best For |
|---|---|---|---|
| Cloudflare | Yes | Official Cloudflare plugin | All-in-one security + CDN |
| Bunny CDN | No | Generic CDN plugin (CDN Enabler) | Low cost, high performance |
| KeyCDN | No | Generic CDN plugin | Simple pull zones |
| StackPath | No | Generic CDN plugin | Edge rules and custom caching |
Step 2: Create a CDN Endpoint (Pull Zone)
Once you pick a provider, you need to create what’s often called a “pull zone.” This is the CDN’s way of knowing where to fetch your site’s files. For Cloudflare, this step is automatic when you add your domain. For Bunny CDN or KeyCDN, you create a pull zone with your site’s URL as the origin.
For example, in Bunny CDN, you create a pull zone, set the origin URL to https://yoursite.com, and enable SSL. The provider gives you a CDN URL like yoursite.b-cdn.net. That URL is what you’ll plug into your plugin later.
Step 3: Install and Configure a CDN Plugin
WordPress doesn’t use CDN URLs by default. You need a plugin that rewrites your static asset URLs to point to the CDN. My go-to is CDN Enabler—it’s lightweight and works with any provider. Alternatively, use your provider’s own plugin (like Cloudflare’s) for tighter integration.
How to set up CDN Enabler:
- Install and activate CDN Enabler from the WordPress plugin repository.
- Go to Settings → CDN Enabler.
- Paste your CDN URL (e.g.,
https://yoursite.b-cdn.net). - In the “Included Directories” field, enter
wp-content/uploads, wp-content/themes, wp-content/plugins. - Leave “Exclude from CDN” blank (unless you know specific files to exclude).
- Enable relative paths if you’re troubleshooting mixed content warnings.
- Save and test.

Step 4: Configure Caching Rules
Your CDN should cache static files aggressively, but you don’t want it to cache dynamic pages or admin content. Most CDNs have a default TTL (time to live) of 24 hours for static assets. That’s fine for images and CSS, but for JavaScript bundles you may want a longer TTL (say 7 days) if your code doesn’t change often.
With Cloudflare, use the “Caching” tab to set cache expiration. For Bunny CDN, edit the pull zone and set Cache Control to “Override” with a max-age of 2592000 seconds (30 days). For dynamic content, ensure your WordPress site sends the correct Cache-Control headers. You can do this via a caching plugin like WP Rocket or W3 Total Cache.
One common mistake: caching the WordPress admin area. Exclude paths like /wp-admin and /wp-login.php from CDN caching. In Cloudflare, use Page Rules to bypass cache for admin pages.
Step 5: Enable SSL (HTTPS)
If your site uses HTTPS, your CDN must serve assets over HTTPS too, or browsers will block mixed content. Most modern CDNs provide free SSL certificates. Cloudflare offers Universal SSL. Bunny CDN lets you issue a free Let’s Encrypt certificate. Enable “Force SSL” in your CDN settings.
Also, in your WordPress site, make sure the “WordPress Address” and “Site Address” in Settings → General use HTTPS. Then update your CDN plugin’s URL to start with https://. Some plugins have a “SSL Support” checkbox—enable it.
Step 6: Test Your CDN Setup
After saving everything, test that assets are actually served from the CDN. Open your site in Chrome, right-click and select “Inspect” to open DevTools. Go to the Network tab and reload the page. Click on an image or CSS file. Look at the “Request URL”——it should start with your CDN URL, not your origin.
You can also use a site like whatsmydns.net to see how assets are cached globally. But nothing beats real browser testing for catching issues like mixed content or missing assets.
Step 7: Monitor and Tweak
A CDN isn’t set-and-forget. Check your CDN provider’s analytics to see cache hit ratios. A low hit ratio (<50%) means many requests go to your origin, defeating the purpose. Adjust your caching rules to include more asset types (like fonts) or increase TTL.
Also, monitor for broken paths. If a plugin updates its CSS file, the old version might be served from the CDN cache. Purge the CDN cache after updating plugins or themes—most providers offer a one-click purge in their dashboard.
Finally, run PageSpeed Insights after a week to see if your scores improved. A properly configured CDN should show noticeable gains in Time to First Byte (TTFB) and Largest Contentful Paint (LCP).
Frequently asked questions
Do I need a CDN if my hosting is already fast?
If your visitors are concentrated in one region and your server responds quickly, you might not see a dramatic improvement. However, a CDN adds resilience for traffic spikes, security against DDoS attacks, and consistent speed for global visitors.
Can I use a CDN with any WordPress hosting?
Yes, CDNs work with all hosting types—shared, VPS, or managed. Some hosts like WP Engine offer built-in CDN, but you can still add a third-party CDN if you prefer.
Will a CDN slow down my site if misconfigured?
Yes, if you cache dynamic pages or don’t purge stale files, users may see outdated content. Also, a slow CDN provider can add latency. Always test after setup.
Does a CDN affect SEO?
Yes, indirectly. Faster page load times can improve user experience and may positively impact Core Web Vitals, which are Google ranking factors. A CDN also helps with uptime and security.
Should I use a free CDN or paid?
Free CDNs like Cloudflare’s free tier are sufficient for small to medium sites. Paid CDNs often offer better performance features, more data centers, and priority support. Choose based on your traffic and performance needs.
2 thoughts on “How to Configure CDN for WordPress: Step-by-Step”