Short answer: A CDN (content delivery network) keeps copies of your site's files on servers around the world and serves each visitor from a nearby location. It speeds up pages for distant visitors, absorbs traffic spikes and can filter attacks. Many small local sites don't need one at first; international sites usually benefit.
Distance still matters on the internet. A visitor in Accra loading images from a server in Europe waits for every file to cross thousands of kilometres. A CDN shortens that trip by keeping copies of your files close to your visitors.
How a CDN works
- A visitor requests your page.
- The CDN serves cached images, CSS and JavaScript (and sometimes whole pages) from the closest edge location.
- Anything not cached is fetched from your hosting server (the "origin"), then cached for the next visitor.
The CDN usually sits in front of your site by taking over your DNS or a subdomain, so visitors' requests reach the CDN first.
What it improves
- Speed for distant visitors, because files travel shorter distances.
- Load on your server, because the CDN handles most file requests.
- Resilience, because cached content can stay available during brief server issues.
- Security, because many CDNs filter malicious traffic and DDoS attacks. See DDoS explained and web application firewalls.
- Modern protocols, such as HTTP/3 and Brotli compression, often switched on for you. See HTTP/3 explained.
What a CDN doesn't fix
- A slow server. Pages that can't be cached still come from your hosting. Fix slow server response first. See TTFB explained.
- Heavy pages. Huge images and scripts are still huge, just closer. See image optimisation.
- Broken code or plugins.
When you need one
- Your visitors are spread across several countries or continents.
- You serve lots of images, video or downloads.
- You get sudden traffic spikes from campaigns or news coverage.
- You want an extra layer of protection against attacks.
When you can wait
- Your audience is mostly in one region near your server.
- Your pages are already light and well cached.
Not sure? Test your site with our website speed test and Google PageSpeed Insights, then compare with a visitor's view from another region. See why is my website slow? and website speed in Africa.
CDN vs choosing a closer server
A CDN speeds up files; choosing a server region close to your audience speeds up everything, including pages that can't be cached, like carts and dashboards. For a mostly local audience, the right server location matters more; for a worldwide one, use both.
Getting started
Services like Cloudflare can sit in front of any hosted site, usually by changing your nameservers. Keep your DNS records accurate when you switch. See what nameservers are and our Cloudflare setup guide.
After switching on a CDN:
- Exclude carts, checkouts, account pages and admin areas from page caching.
- Purge the CDN cache after big design changes.
- Make sure SSL is set to the strictest mode your host supports, so traffic is encrypted all the way.
Frequently asked questions
Does a CDN replace hosting?
No. Your site still lives on your hosting server; the CDN distributes copies.
Can a CDN break my site?
Caching dynamic pages like carts or account areas can cause problems. Exclude them from caching.
Is a CDN good for SEO?
Indirectly, yes. Faster pages improve user experience and Core Web Vitals. See Core Web Vitals.
Is there a free CDN?
Yes. Some providers offer free plans that suit most small websites, with paid plans adding more features.



