Speed & performance · Guide
How to Set Up a CDN for WordPress
Short answer
To set up a CDN for WordPress, pick a provider such as Cloudflare, Bunny CDN, or KeyCDN, create an account, and connect it to your site. With Cloudflare you change your nameservers and install the official plugin, while Bunny and KeyCDN use a pull zone plus a plugin. Then check the cache headers to confirm files load from the CDN.
Key takeaways
- A CDN stores copies of images, CSS, and JavaScript on servers near each visitor, so static files travel a shorter distance.
- Cloudflare's Free plan costs $0 per month and includes a CDN, unmetered DDoS protection, and a Universal SSL certificate.
- Nameserver changes at your registrar can take up to 24 hours to process, so allow waiting time after the switch.
- Bunny CDN's Standard tier starts at $0.01 per GB in Europe and North America, while KeyCDN starts at $0.04 per GB there.
- APO on Cloudflare caches HTML at the edge, costs $5 per month on the Free plan, and does not support WordPress multisite.
- Check a CDN with cache headers: working Cloudflare APO shows cf-cache-status HIT, cf-apo-via tcache, and cf-edge-cache cache.
What is a CDN for WordPress?
A CDN is a network of servers around the world that stores copies of your site files and serves them from the server nearest each visitor.
Your origin server still holds the original site. The CDN keeps copies of images, CSS, and JavaScript at edge locations, so those files travel a shorter distance to each visitor.
Do you need a CDN for your WordPress site?
You need a CDN if a large share of your visitors live far from your server, or if your pages carry many images and scripts.
Google's web.dev guide to Largest Contentful Paint says a good LCP is 2.5 seconds or less, measured at the 75th percentile of page loads.
A CDN helps the file delivery part of that time, though it cannot fix a slow server or an oversized hero image. For a wider speed plan, see how to speed up WordPress.
What do you need before you set up a CDN?
You need a self-hosted WordPress site, admin access to it, and access to your domain registrar or DNS settings.
You also need a CDN account and a backup made before you change DNS or install a plugin. DNS changes can take time to spread, so work in a quiet period with your registrar login ready. Note your home page load time first, so you can compare it later.
How do you set up Cloudflare for WordPress?
You set up Cloudflare by adding your domain to Cloudflare, replacing your nameservers at your registrar, and then installing the official Cloudflare plugin in WordPress.
Start by creating a free Cloudflare account and adding your site. Cloudflare scans your current DNS records, so check that mail records such as MX, SPF, and DKIM were copied correctly.
Cloudflare's plans page lists the Free plan at $0 per month and the Pro plan at $20 per month when billed annually, or $25 per month when billed monthly, as of November 2026. The same page lists a CDN, unmetered DDoS protection, and a Universal SSL certificate on every plan, including Free.
Next, replace the nameservers at your registrar with the two Cloudflare nameservers shown in your dashboard.
Cloudflare's DNS setup docs say registrars can take up to 24 hours to process the change, and your domain shows a status of Active once it is done.
Turn off DNSSEC at your registrar first if your domain uses it, because changing nameservers while DNSSEC is active can leave your domain unreachable.
Then install the plugin. In WordPress, go to Plugins, then Add New, search for Cloudflare, and install and activate the official plugin.
Connect the plugin with an API token. In Cloudflare, go to Account API Tokens, select Create Token, choose the WordPress template, and copy the token. In WordPress, open the Cloudflare plugin settings, sign in, paste the token, select Save API Credentials, and select Apply for the recommended settings.
Should you turn on Automatic Platform Optimization?
Automatic Platform Optimization, or APO, caches HTML pages at the edge as well as static files. Cloudflare's APO docs say APO can cache dynamic content such as HTML, which cuts round trips to the origin and improves time to first byte (TTFB).
For users on the Free plan, Cloudflare's plugin activation docs say to buy APO before installing the WordPress plugin. The same docs say APO costs $5 per month as an add-on on the Free plan and is included with Pro and Business plans, as of November 2026.
If you use APO, turn off page caching plugins such as WP Rocket or W3 Total Cache while you set it up, because two caching layers can serve stale pages. APO does not support WordPress multisite, and it bypasses the cache for logged-in users.
How do you set up Bunny CDN for WordPress?
You set up Bunny CDN by creating a pull zone in Bunny, then connecting it to WordPress with the official bunny.net plugin or a caching plugin.
A pull zone tells Bunny where to fetch your files. Bunny pulls each file from your origin server the first time it is requested, then stores a copy at the edge.
Create the pull zone first. In your Bunny dashboard, go to CDN, then Add Pull Zone, enter a name, set the origin type to Origin URL, and enter your site address with https://.
Bunny's CDN pricing docs list the Standard tier at $0.01 per GB in Europe and North America, $0.03 per GB in Asia and Oceania, $0.045 per GB in South America, and $0.06 per GB in the Middle East and Africa, as of November 2026.
The Volume tier starts at $0.005 per GB for the first 500 TB per month.
Next, install the official plugin. In WordPress, go to Plugins, then Add New, search for bunny.net, and install and activate it.
Bunny's WordPress plugin docs say the plugin rewrites static content links with CDN URLs. Follow its setup wizard to connect your Bunny account and select your pull zone.
How do you set up KeyCDN for WordPress?
You set up KeyCDN by creating a pull zone in KeyCDN and then pointing WordPress at the zone URL with the CDN Enabler plugin.
In the KeyCDN dashboard, go to Zones, select Add Zone, choose the Pull type, enter a zone name, and enter your site URL as the origin URL. KeyCDN then gives you a zone URL ending in kxcdn.com.
KeyCDN's pricing page lists $0.04 per GB in North America and Europe for the first 10 TB per month, $0.08 per GB in Asia and Oceania, and $0.10 per GB in Africa and Latin America, as of November 2026.
The same page lists a $4 per month minimum usage charge and a $49 minimum payment to add credit.
Then install CDN Enabler in WordPress: go to Plugins, then Add New, search for CDN Enabler, and install and activate it. Open Settings, then CDN Enabler, enter your CDN URL with https:// and no trailing slash, and save. Clear any caching plugin cache so pages rebuild with the new URLs.
What if your host already includes a CDN?
You may not need a separate CDN account at all, because many managed hosts include one in the plan price.
WP Engine uses Cloudflare as the CDN included with each plan, according to WP Engine's CDN support docs. The CDN turns on by itself once your DNS points to the Advanced Network or to Global Edge Security. The same docs say static files are cached for 24 hours by default.
To clear the WP Engine cache by hand, open Cache for the environment in the User Portal and click Clear cache under Network cache.
Kinsta also includes a CDN on every plan at no extra cost, built on Cloudflare's network. In MyKinsta, go to Sites, select your site, open Kinsta CDN, and click Enable Kinsta CDN. For a host-by-host comparison, see does hosting affect WordPress speed.
SiteGround uses its own CDN. SiteGround's CDN docs say your domain must use SiteGround nameservers, ns1.siteground.net and ns2.siteground.net. In Site Tools, go to Speed, then CDN, pick a plan, and click Activate.
The same SiteGround docs list a default cache duration of 12 hours for dynamic resources on the Premium plan, and say a full cache purge can take up to 60 seconds. If you change the nameservers after activation, the CDN stops working.
How do you check that the CDN is working?
You check a CDN by looking at where your files load from and by reading the cache headers your server returns.
Open a page, right-click, and select View page source. If the image, CSS, and JavaScript addresses start with your CDN hostname, the rewrite is working.
For Cloudflare APO, Cloudflare's verify docs say three headers show when APO is working: CF-Cache-Status with a value of HIT, cf-apo-via with a value of tcache, and cf-edge-cache with a value of cache, platform=wordpress.
Read the headers with curl -sI https://yourdomain.com | grep "cf-cache-status". WP Engine's docs say the common replies are DYNAMIC, HIT, and MISS, and no reply means the CDN is not set up.
Load the home page twice from a private browser window. The first load fills the cache, and the second should come from the edge. Then check pages a CDN must never cache: log in, open the cart and checkout if you run a store, and submit a test form.
What mistakes should you avoid?
The most common mistake is changing DNS before you have checked every record, which can break email.
Copy all DNS records into the new provider before you switch nameservers, and pay close attention to MX, SPF, DKIM, and DMARC records. If mail records are missing after the move, email stops.
A second mistake is caching pages that should stay private. Exclude the login page, the admin area, the cart, the checkout, and account pages from full-page caching. For the settings that control this, see Cloudflare cache rules for WordPress.
A third mistake is forgetting to purge the cache after an edit. When a page looks unchanged after you update it, purge that page from the CDN before you change theme or plugin settings. A fourth mistake is running two caching plugins beside a full-page CDN, so pick one page cache and test it first.
Allow time for the change to settle. Nameserver changes can take up to 24 hours, and the first visit to each page fills the cache, so judge speed on the second load. For the metric that matters most then, see how to reduce TTFB in WordPress.
| Option | Starting price as of November 2026 | Setup path | Best fit |
|---|---|---|---|
| Cloudflare | $0 per month on the Free plan | Nameserver change plus official plugin | DNS, CDN, and security in one place |
| Bunny CDN | $0.01 per GB in Europe and North America | Pull zone plus official plugin | Low pay-as-you-go prices |
| KeyCDN | $0.04 per GB in North America and Europe | Pull zone plus CDN Enabler plugin | Simple pull zones, no request charges |
| Host CDN (Kinsta, WP Engine, SiteGround) | Included in the hosting plan | Toggle or DNS step in the host panel | Sites already on managed hosting |
How long does CDN setup take?
Basic CDN setup takes 30 to 60 minutes of active work, plus waiting time for DNS changes.
DNS changes can take up to 24 hours. Add extra time for full-page caching, and test the login page, the cart, and one form first. To track the result, see how to pass Core Web Vitals in WordPress.
Frequently asked questions
Do I need a CDN if my visitors are all in one country?
Probably not yet. A CDN helps most when visitors are spread across countries or far from your server, because distance adds delay to every file. If your audience is local and your pages are light, a good host and a caching plugin may be enough for now. Add a CDN when traffic grows or visitors come from further away.
Is Cloudflare really free for WordPress?
Yes, the basic CDN is free. Cloudflare's Free plan costs $0 per month and includes a CDN, unmetered DDoS protection, and a Universal SSL certificate. The paid add-on is Automatic Platform Optimization, which caches HTML pages and costs $5 per month on the Free plan. Pro plans start at $20 per month when billed annually.
Will a CDN break my WordPress login or checkout?
It should not if you exclude private pages from full-page caching. The login page, the admin area, the cart, the checkout, and account pages must stay fresh and never serve a cached copy to the wrong person. Cloudflare APO already bypasses the cache for logged-in users, but you should still test login, cart, and checkout after setup.
How long does it take for a CDN to start working?
The active setup takes 30 to 60 minutes, but DNS changes can take up to 24 hours to spread. The first visit to each page also fills the cache, so the second load is the one to judge. If a page still loads from your origin after a day, check the nameservers and the cache headers.
Can I use two CDNs on one WordPress site?
No, use only one CDN at a time. Running a host CDN and a separate CDN together can double-cache pages, serve stale content, and make faults harder to trace. Pick the one that fits your host and budget, and turn the other one off before you test.
What should I do if my site looks unchanged after an edit?
Purge the changed page from the CDN first, then reload it in a private browser window. A purge tells every edge server to fetch a fresh copy from your origin. If the old page still shows, check that you purged the right URL and that no second caching layer, such as a page cache plugin, still holds the old copy.
Sources
- Automatic Platform Optimization: About Cloudflare Developer Docs
- Activate the Cloudflare WordPress plugin Cloudflare Developer Docs
- Verify APO works Cloudflare Developer Docs
- Cloudflare plans Cloudflare
- WordPress Plugin bunny.net Documentation
- CDN pricing bunny.net Documentation
- KeyCDN pricing KeyCDN
- Configure Content Delivery Network WP Engine Support
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
