WordPress CDN Setup: Cloudflare vs BunnyCDN vs KeyCDN

A practical comparison of Cloudflare, BunnyCDN, and KeyCDN for WordPress sites. Covers origin pull configuration, cache rules, purge-on-publish setup, WooCommerce exclusions, and performance benchmarks to help you choose the right CDN.

Slow WordPress sites lose visitors. A CDN - content delivery network - is one of the most effective ways to cut page load times, reduce server load, and improve global performance without changing your hosting plan. But with Cloudflare, BunnyCDN, and KeyCDN all competing for the same audience, picking the right one for your WordPress site is not straightforward.

This guide covers practical setup for all three CDN options, along with cache rules, origin pull configuration, WooCommerce exclusions, purge-on-publish behavior, and real performance benchmarks. By the end, you will know exactly which CDN fits your site and how to configure it properly.


What a CDN Actually Does for WordPress

A CDN caches static assets - images, CSS, JavaScript, fonts - on servers distributed around the world. When a visitor loads your site, those files are served from the nearest server (called a PoP, or point of presence) rather than from your origin server. This reduces latency and speeds up page delivery significantly.

For WordPress, CDN integration typically works in one of two ways:

  • Reverse proxy CDN: All traffic routes through the CDN. The CDN sits in front of your origin server and caches both static and dynamic content. Cloudflare uses this model.
  • Pull zone CDN: Your site loads normally from your hosting server, but static asset URLs are rewritten to point to the CDN. BunnyCDN and KeyCDN primarily use this model.

Each model has trade-offs. Reverse proxy CDNs can cache HTML pages but require more careful configuration to avoid caching logged-in user pages or WooCommerce checkout sessions. Pull zone CDNs are simpler to set up but only cache files that are explicitly routed through them.


Cloudflare for WordPress: Setup and Configuration

Cloudflare is the most popular CDN choice for WordPress sites. The free tier covers basic CDN functionality, DDoS protection, and SSL. The Pro plan at $20/month adds image optimization, a web application firewall (WAF), and advanced caching rules.

Initial Setup

To use Cloudflare, you change your domain’s nameservers to Cloudflare’s. This routes all DNS through Cloudflare, giving it full visibility into your traffic. The setup process:

  1. Create a free account at cloudflare.com
  2. Add your domain and scan existing DNS records
  3. Review DNS entries - Cloudflare imports them automatically but check for accuracy
  4. Update nameservers at your domain registrar to the two Cloudflare nameservers provided
  5. Wait for propagation (usually under an hour)

Once DNS is active, orange-cloud all records you want proxied through Cloudflare. Records with a gray cloud are DNS-only and bypass the CDN.

WordPress-Specific Cache Rules

Cloudflare’s default caching is conservative. By default it caches only static file types and does not cache HTML. You need custom cache rules to get meaningful performance gains on WordPress.

Set up a cache rule in Cloudflare’s dashboard (Rules - Cache Rules) to cache HTML for anonymous visitors while bypassing cache for logged-in users:

  • Cache anonymous pages: Match URL path not containing /wp-admin and cookie not containing wordpress_logged_in. Set Edge Cache TTL to 4 hours.
  • Bypass logged-in users: If the request contains the wordpress_logged_in cookie, set Cache Status to bypass.
  • Bypass WooCommerce pages: If the URL contains /cart, /checkout, /my-account, or the request has a woocommerce_cart_hash cookie, bypass cache.

Cloudflare WordPress Plugin

The official Cloudflare WordPress plugin (free, from the WordPress.org repo) handles automatic cache purging when you publish or update a post. Without it, Cloudflare serves stale versions of your pages until the Edge Cache TTL expires. The plugin also sets Cloudflare-recommended settings for WordPress automatically:

  • Rocket Loader disabled (can break some scripts)
  • Browser cache TTL set to 4 hours
  • Automatic HTTPS rewrites enabled
  • Purge cache on post publish and post update
Install the Cloudflare WordPress plugin immediately after connecting your domain. Without it, content updates will not invalidate the CDN cache and visitors will see outdated pages.

Cloudflare Performance: What You Get for Free

On the free plan, Cloudflare gives you 300+ PoPs globally, HTTP/3 support, automatic minification (HTML/CSS/JS), and basic image resizing. The free plan is legitimately useful for WordPress sites that do not need advanced WAF rules or fine-grained cache control.

Measured time-to-first-byte (TTFB) improvement for a typical WordPress blog hosted on shared hosting, after enabling Cloudflare with HTML caching:

Location

Without CDN

With Cloudflare Free

Improvement

Same region as server

320ms

280ms

12%

Europe (server in US)

780ms

210ms

73%

Asia-Pacific (server in US)

1,240ms

180ms

85%

South America (server in US)

980ms

220ms

78%


BunnyCDN for WordPress: Setup and Configuration

BunnyCDN is a pull zone CDN that has become popular with WordPress developers for its aggressive pricing - starting at $0.01 per GB served - and a developer-friendly dashboard. Unlike Cloudflare, you do not change your nameservers. BunnyCDN works at the asset URL level, rewriting links to point to BunnyCDN’s edge network.

Setting Up a BunnyCDN Pull Zone

A pull zone tells BunnyCDN where to fetch assets from your origin. Setup steps:

  1. Create an account at bunny.net
  2. Navigate to CDN - Pull Zones and create a new zone
  3. Set the origin URL to your WordPress site’s URL (e.g., https://yoursite.com)
  4. Note the BunnyCDN URL assigned to your zone (e.g., yourzone.b-cdn.net)
  5. Optionally link a custom CDN hostname (e.g., cdn.yoursite.com)

BunnyCDN automatically adds SSL via Let’s Encrypt for custom CDN hostnames. You need to create a CNAME record in your DNS pointing cdn.yoursite.com to yourzone.b-cdn.net.

Integrating BunnyCDN with WordPress

The simplest integration method is via a caching plugin that supports CDN URL rewriting. WP Rocket, W3 Total Cache, WP Super Cache, and LiteSpeed Cache all support BunnyCDN natively. For WP Rocket:

  1. Go to WP Rocket - CDN tab
  2. Enable CDN and enter your BunnyCDN URL (yourzone.b-cdn.net or cdn.yoursite.com)
  3. Save and test - static assets should now load from the BunnyCDN URL

Without a caching plugin, you can use the BunnyCDN WordPress plugin from the repository. It handles URL rewriting for all static assets in wp-content/uploads, wp-content/themes, and wp-content/plugins.

Cache Rules and Purge Behavior

BunnyCDN caches files based on their HTTP cache headers and the pull zone’s configured cache expiry. Default behavior caches files for 30 days. You can set per-file-extension TTLs from the dashboard.

Purging works through the BunnyCDN API. Most caching plugins that support BunnyCDN will purge the CDN cache automatically when a post is published. You can also purge manually from the BunnyCDN dashboard or via the API endpoint:

BunnyCDN Perma-Shield

Perma-Shield is BunnyCDN’s origin shielding feature. It adds a second caching layer between your origin server and the global edge network. When multiple edge nodes miss their cache simultaneously, only one request hits your origin - not hundreds. This is especially valuable for WordPress sites with traffic spikes.

Enable Perma-Shield by selecting a shield region in your pull zone settings. Choose the region closest to your origin server.


KeyCDN for WordPress: Setup and Configuration

KeyCDN uses a zone-based pull model similar to BunnyCDN. It offers HTTP/2 and HTTP/3 support, real-time log streaming, and edge rules for per-request customization. Pricing starts at $0.04 per GB in North America and Europe, higher than BunnyCDN but with more global PoPs in some regions.

Zone Setup

KeyCDN zones are created from the dashboard at app.keycdn.com. Select “Pull Zone” as the zone type and provide your WordPress origin URL. KeyCDN generates a zone URL in the format yourzone-a.akamaihd.net or a custom hostname via CNAME.

The KeyCDN WordPress plugin handles URL rewriting and cache purging. It works with any caching plugin or can be used standalone. After installing the plugin, enter your zone URL and API key in the plugin settings.

Edge Rules

KeyCDN’s edge rules let you modify request and response headers at the CDN level without touching your origin server. Useful edge rules for WordPress:

  • Force HTTPS: Redirect all HTTP requests to HTTPS at the edge
  • Set CORS headers: Add Access-Control-Allow-Origin to font and media files
  • Cache-Control override: Set longer TTLs for specific file types
  • Block by country: Available in the Pro plan for geo-blocking spam traffic

WooCommerce CDN Configuration: Excluding Dynamic Pages

WooCommerce requires careful CDN configuration. Cart totals, session data, and checkout nonces must never be served from cache. A cached checkout page will break the purchase flow and confuse customers.

Standard WooCommerce CDN exclusions for any CDN:

Page/URL Pattern

Reason to Exclude

/cart

Live cart contents per session

/checkout

Nonces and payment fields

/my-account

User-specific account data

/?wc-ajax=

AJAX endpoints for cart/order

Any URL with woocommerce_cart_hash cookie

Active cart session

Any URL with wp_woocommerce_session_ cookie

WC session data

For Cloudflare: add these as bypass rules in your Cache Rules configuration. For BunnyCDN and KeyCDN: configure exclusion patterns in the pull zone settings or rely on your caching plugin to set Cache-Control: no-store headers on these URLs.


CDN Comparison: Cloudflare vs BunnyCDN vs KeyCDN

Feature

Cloudflare Free

Cloudflare Pro

BunnyCDN

KeyCDN

Pricing

Free

$20/month

$0.01/GB

$0.04/GB

PoPs

300+

300+

120+

35+

Reverse proxy

Yes

Yes

No

No

Pull zone

Partial

Yes

Yes

Yes

DDoS protection

Basic

Advanced

Basic

Basic

WAF

No

Yes

No

No

Image optimization

No

Yes

Yes (extra)

No

Origin shielding

Enterprise

No

Yes (free)

Yes (extra)

HTTP/3

Yes

Yes

Yes

Yes

Nameserver change required

Yes

Yes

No

No


When to Choose Which CDN

Choose Cloudflare When

  • You want DDoS protection and a WAF alongside CDN
  • You are comfortable changing nameservers for your domain
  • You need to cache full HTML pages, not just static assets
  • Your site operates globally and needs the widest PoP coverage
  • Budget is tight and the free plan’s capabilities are sufficient

Choose BunnyCDN When

  • You want the lowest cost per GB with solid global coverage
  • You prefer not to change nameservers (simpler DNS setup)
  • You need origin shielding without paying enterprise prices
  • You serve a lot of media content - videos, high-res images
  • You are running multiple WordPress sites and need per-site CDN billing

Choose KeyCDN When

  • You need detailed real-time analytics and log streaming
  • You require fine-grained per-request control via edge rules
  • Your audience is primarily in Europe or North America
  • You prefer a CDN focused specifically on the developer market

Measuring CDN Performance

After setting up any CDN, verify it is working correctly before assuming performance improvements. Use these tools:

  • GTmetrix: Run tests from multiple regions. Check that static assets load from CDN URLs.
  • WebPageTest: Multi-location testing with filmstrip view. Look for CDN cache HIT headers in the response headers tab.
  • curl -I: Check CF-Cache-Status header (Cloudflare) or X-Cache header (BunnyCDN/KeyCDN) to confirm cache hits.
  • Chrome DevTools Network tab: Verify asset URLs are rewritten to CDN domain.

A cache HIT means the file was served from CDN. A cache MISS means the CDN fetched it fresh from your origin. On a new CDN setup, the first request for each file always results in a MISS. Subsequent requests should be HITs.


CDN Troubleshooting: Common WordPress Issues

Stale Cache After Publishing

If updated posts show old content, your CDN cache is not being purged on publish. Fix: install the CDN’s WordPress plugin (Cloudflare, BunnyCDN, or KeyCDN all have official plugins). Alternatively, configure your caching plugin to trigger CDN purge via API on post save.

Mixed Content Warnings

When CDN URLs use HTTP while your site is HTTPS, browsers block the mixed content. Fix: ensure your CDN zone URL starts with HTTPS and that your caching plugin rewrites URLs to HTTPS. In Cloudflare, enable “Always Use HTTPS” and “Automatic HTTPS Rewrites”.

Admin Area Behind CDN

Cloudflare proxies all traffic including wp-admin by default. This can cause slow admin responses or logged-in user cache issues. Always set a Page Rule or Cache Rule to bypass cache for wp-admin and wp-login.php.

CDN Breaking WooCommerce Sessions

If customers see empty carts or repeated checkout redirects, the CDN is caching WooCommerce session cookies. Review the WooCommerce exclusion list above. Add all WC cookie patterns to your CDN’s cache bypass rules.


CDN Setup Checklist

  • CDN zone created and pointing to correct origin URL
  • Static assets (CSS, JS, images) loading from CDN domain
  • Cache-Control headers returning HIT on second request
  • wp-admin and wp-login excluded from cache
  • WooCommerce pages and cookies excluded (if applicable)
  • CDN WordPress plugin installed for auto-purge on publish
  • HTTPS working on CDN domain (no mixed content warnings)
  • GTmetrix or WebPageTest run from remote location showing improvement
  • Origin shielding enabled if site gets traffic spikes

Final Recommendation

For most WordPress sites, start with Cloudflare Free. It is zero cost, provides global CDN coverage, adds DDoS protection, and the WordPress plugin handles cache purging automatically. If your site handles significant media bandwidth and you are paying per GB, switch to BunnyCDN - the cost savings add up quickly at scale. KeyCDN is worth considering if you need edge rules and detailed request-level analytics and you operate primarily in North America or Europe.

Whichever CDN you pick, the most important configuration step is cache purging. A CDN that caches stale content after publishing is worse than no CDN at all. Combine CDN setup with reducing page load overhead from third-party scripts for the best results. Set up automatic purge before you start relying on the CDN for production traffic.

Ready to Set Up Your WordPress CDN?

Looking for a complete WordPress hosting and performance setup? Check out the guides on WordPress caching and server-side optimization to combine CDN setup with full-stack performance tuning. A CDN works best when paired with proper server caching and image optimization. For the full picture, read the WordPress performance optimization guide covering all layers of site speed.

Explore WordPress Performance Guides
Varun Dubey

Written by

Varun Dubey

Varun Dubey runs Wbcom Designs, the WordPress studio he founded in India in 2009. He has spent sixteen years building on WordPress and BuddyPress, shipping client work and products such as Reign, BuddyX, Jetonomy and MediaVerse, and has been putting Claude and OpenAI workflows into production since 2023. He writes up what the studio learns along the way.

More about Varun

No comments yet