Short answer: A CDN speeds up your WordPress site by caching static files like images, CSS, and JavaScript on global servers. To maximize performance, choose a CDN with WordPress integration, cache static assets, set proper TTLs, exclude dynamic content, and enable CDN-specific caching plugins.
Key takeaways
- Choose a CDN that integrates easily with WordPress.
- Cache static files like images, CSS, and JS on the CDN.
- Set appropriate cache expiration times (TTL).
- Exclude dynamic pages like cart and checkout from CDN cache.
- Use a WordPress caching plugin that works with your CDN.
- Monitor CDN performance and adjust rules as needed.
What you will find here
- 1. Choose a CDN That Plays Nicely with WordPress
- 2. Cache Static Files — But Know What They Are
- 3. Set Proper Cache Expiration Times (TTL)
- 4. Exclude Dynamic Pages from CDN Cache
- 5. Use a WordPress Caching Plugin That Understands CDNs
- CDN and Core Web Vitals: The Connection
- How to Check If Your CDN Is Working
If you’re serious about WordPress speed, a CDN (Content Delivery Network) is one of the most effective tools you can add. It reduces latency by serving your site’s static files from servers located near your visitors. But simply signing up for a CDN isn’t enough. You need to configure it properly. Here are five practical tips to speed up your WordPress site with a CDN.
1. Choose a CDN That Plays Nicely with WordPress
Not all CDNs are equal when it comes to WordPress. Some offer one-click integrations, while others require manual setup. Look for a CDN that either has a dedicated WordPress plugin or easily integrates via a plugin like W3 Total Cache or WP Rocket. This saves you from messing with DNS records and origin pull settings.
Many popular CDNs — such as Cloudflare, StackPath, and KeyCDN — have direct WordPress plugins. These plugins handle SSL, set caching rules, and even purge the cache when you update content. If you’re just starting, Cloudflare’s free plan is a solid choice with built-in WordPress optimizations.

2. Cache Static Files — But Know What They Are
Your CDN’s main job is caching static files and serving them quickly. These include images, JavaScript, CSS, fonts, and PDFs. Dynamic content like PHP pages and database queries should still come from your origin server, unless you’re using an advanced setup like full-page caching.
Most CDN setups assume you want to cache these assets by default. But double-check your configuration. For example, in Cloudflare, you can create page rules to cache static extensions with a long expiration. A common rule is to cache everything except the admin area and logged-in users. This ensures visitors get a fast, cached version of images and scripts.
3. Set Proper Cache Expiration Times (TTL)
TTL (Time To Live) determines how long the CDN holds a file before checking for a new version. Too short, and you miss the performance benefit. Too long, and visitors might see outdated content. For most static assets, a TTL of one week to one month is fine.
| Asset Type | Recommended TTL |
|---|---|
| Images (JPG, PNG, WebP) | 1 month |
| CSS and JavaScript | 1 week (or longer if you version URLs) |
| Fonts | 1 month |
| PDFs | 1 month |
When you update a file, change its filename or version query string (e.g., style.css?v=2) so the CDN fetches the new one immediately. Many WordPress plugins do this automatically for CSS and JS files.
4. Exclude Dynamic Pages from CDN Cache
Not everything should be cached on a CDN. Dynamic pages like your WooCommerce cart, checkout, my-account, and any user-specific content should always be served fresh from your server. Caching those would break functionality — users would see someone else’s cart or outdated order status.
Most CDN plugins let you exclude URLs by pattern. For instance, you can exclude paths like /cart/, /checkout/, /my-account/, and /wp-admin/. Also exclude pages that rely on query parameters, unless you have a specific reason to cache them. This keeps your site functional while still speeding up the rest.
If you’re troubleshooting cache issues, check out our guide on Solving CDN Cache Issues on WordPress.

5. Use a WordPress Caching Plugin That Understands CDNs
A caching plugin on your WordPress server works alongside your CDN. It generates static HTML files and handles local caching. Popular options like W3 Total Cache, WP Super Cache, or WP Rocket can integrate directly with your CDN. For example, W3 Total Cache lets you enter your CDN credentials and automatically upload static files to it.
These plugins also manage cache purging. When you publish a new post or update a plugin, they tell the CDN to clear its cache so fresh content appears. Without this, you’d have to manually purge the CDN every time you make a change. That’s a headache you don’t need.
If you’re new to caching, check out our Beginner’s Guide to WordPress Caching for the basics. And watch out for common mistakes — our article on 5 Common WordPress Caching Mistakes covers pitfalls to avoid.
CDN and Core Web Vitals: The Connection
A properly configured CDN can improve your Core Web Vitals, especially Largest Contentful Paint (LCP). By serving images and scripts from a nearby server, you reduce the time it takes to render the biggest element on the page. This directly helps your LCP score.
But a CDN alone isn’t a magic fix. You still need optimized images, minimal JavaScript, and good server response times. Combine a CDN with solid hosting, image compression, and a caching plugin for the best results.
How to Check If Your CDN Is Working
After setup, verify that your CDN is actually serving files. Use browser developer tools (open Network tab) and look at the domain of static files. If they show your CDN’s domain (e.g., cdn.example.com), it’s working. You can also use online tools like Pingdom or GTmetrix to see if resources come from a CDN server.
If you see your origin server URL for assets, your CDN isn’t configured correctly. Check your caching plugin settings and DNS records. Sometimes a simple plugin reinstall fixes it.
Speed optimization is an ongoing process. A CDN is a powerful tool, but it needs proper setup and maintenance. Start with these five tips, monitor your site’s performance, and adjust as your traffic patterns change.
Frequently asked questions
What does a CDN do for a WordPress site?
A CDN (Content Delivery Network) caches static files like images, CSS, and JavaScript on a network of global servers. When a visitor requests your site, the CDN serves those files from the nearest server, reducing latency and speeding up page load times.
Do I need a CDN for a small WordPress site?
If your visitors are mostly local, a CDN may not be necessary. However, even small sites benefit from a CDN if you have a global audience. The free tier of many CDNs is cost-effective and can improve load times for visitors far from your hosting server.
Can a CDN conflict with my WordPress caching plugin?
Not if configured correctly. Most caching plugins like W3 Total Cache and WP Rocket have built-in CDN support. They manage cache purging automatically. Conflicts happen when both systems cache the same content incorrectly. Use a plugin that integrates with your CDN to avoid issues.
How do I clear my CDN cache after updating WordPress content?
Most CDN plugins offer a purge button. For example, in Cloudflare, you can use the WordPress plugin to purge everything or specific URLs. Alternatively, log into your CDN dashboard and use the purge tool. Caching plugins often send a purge request automatically when you save changes.
Does a CDN help with Core Web Vitals?
Yes, especially Largest Contentful Paint (LCP). By serving images and scripts from a nearby server, a CDN reduces round-trip time, helping the main content load faster. However, you also need optimized images and efficient code to see significant improvements.