What a CDN Does and When Your Website Needs One
A CDN stores copies of your files on servers near visitors. Learn how it works, what it speeds up, what it cannot fix, and how to decide whether you need one.
A content delivery network, or CDN, is a network of servers spread across many locations that keeps copies of your site's files and delivers them to visitors from a nearby point. Instead of every request travelling all the way to your hosting server, many are answered close to the visitor.
This article is about the concepts: what a CDN really does, what it does not do, and how to judge whether your site would benefit. If you want setup steps for a specific provider, see our article on Cloudflare's free CDN.
The problem a CDN solves
Data travels fast, but not instantly. A visitor on another continent connecting to your origin server pays for the physical distance in every round trip. Loading one page may need dozens of requests for HTML, stylesheets, scripts, fonts and images, and each one adds a little latency. A CDN shortens that distance for files that can be reused.
How a CDN works
- A visitor requests a file, such as your logo or a stylesheet.
- The request reaches a CDN edge server near the visitor.
- If the edge has a fresh copy, it answers immediately. This is a cache hit.
- If not, the edge fetches the file from your origin server, stores a copy and sends it on. This is a cache miss, and the next visitor nearby gets a hit.
- Cache rules, including expiry times set by your headers, decide how long the copy stays.
What a CDN speeds up
- Static files: images, CSS, JavaScript, fonts and downloads are ideal because they are the same for every visitor.
- Connection setup: a nearby edge can complete the TLS handshake faster, and a CDN typically supports modern protocols such as HTTP/2 and HTTP/3.
- Origin load: when the CDN answers, your server does not have to, which helps during traffic peaks.
- Image delivery: some CDNs can resize or convert images, though features vary by provider and plan.
What a CDN does not fix
It helps to be honest about the limits.
- A slow database query or an overloaded origin still makes uncached dynamic pages slow.
- Bloated pages with several megabytes of images and scripts remain heavy; the CDN only delivers them from closer by.
- Pages personalised per user, such as account areas and checkouts, generally should not be cached and still go to the origin.
- A CDN does not replace good hosting. It sits in front of it.
Caching HTML as well as static files
Many CDNs can also cache whole HTML pages, which removes nearly all origin work for anonymous visitors. It is powerful for blogs and brochure sites, but needs care: logged-in users, carts and form pages must be excluded, and you need a way to purge the cache after updating content. Caching HTML without proper rules is a common cause of "my changes do not show" complaints.
Security side benefits
Because visitors connect to the CDN first, many providers add protective layers: absorbing large floods of traffic, filtering known malicious requests, and hiding the origin server's address. The depth of protection depends on the provider and plan, so treat it as a useful extra rather than a complete defence. Our articles on DDoS protection and web application firewalls cover these topics.
Do you need one?
If you are unsure, the support team can look at your setup through the contact page.
| Situation | CDN value |
|---|---|
| Local site, visitors mostly in one region near your server | Modest; still helps with load and protection |
| Visitors spread across countries | High |
| Image-heavy or media-heavy pages | High |
| Traffic spikes from campaigns or press | High |
| Small internal tool with few users | Low |
Practical cautions
- Set sensible cache lifetimes for static files so the CDN and browsers can reuse them.
- Use versioned file names or purge the cache when you update CSS and JavaScript.
- Test the site while logged in and logged out after enabling the CDN.
- Check that HTTPS works end to end between visitor, CDN and origin.
Origin shielding and cache hit ratio
Two terms come up often when people talk about CDN performance. The cache hit ratio is the share of requests answered from the edge rather than your origin; a higher ratio means less work for your server. You raise it by caching more file types, setting longer lifetimes for static assets and avoiding unnecessary query strings that create many unique URLs for the same file.
Some providers also offer origin shielding, where edge locations fetch from one intermediate cache instead of all hitting your origin separately after a purge. This matters mostly for large sites with heavy traffic. A typical small site will not need it, but it is useful to know the term when you read a provider's documentation.
Cost and complexity
Many CDNs have a free tier that covers the basics for small sites, with extra features on paid plans. The real cost is rarely money. It is the time spent understanding cache rules and testing that nothing breaks. Start with static files, confirm everything works, and only then consider caching HTML.
CDN on your Zebra Hosting site
Cloudflare CDN is available on sites hosted with Zebra Hosting Cloud, and free SSL certificates come with every hosting plan. Read how it fits together on the CDN page. Support is available in 17 languages.