You may have heard that a CDN makes websites faster. Sometimes it does, and sometimes it only adds another thing to manage. This article explains what a CDN is, what it does and does not do, and how to decide whether your site needs one.
What a CDN is
A content delivery network, or CDN, is a group of servers spread across many locations. MDN, Mozilla's web documentation, says these servers store duplicate copies of data so that requests can be served by the servers closest to each visitor.
Your web host still stores your site. The CDN keeps copies of files, such as images, stylesheets and scripts, in more places, and may also keep copies of whole pages.
How it works
Cloudflare's learning centre explains the main steps:
- A visitor asks for your page.
- The request goes to a nearby CDN server, called an edge server.
- If the edge server has a copy of the file, it sends it straight away. If not, it fetches it from your host, then keeps a copy for the next visitor.
The shorter the distance, the lower the delay. Cloudflare also says a CDN does not replace web hosting, because your own server still holds the original files.
What a CDN can do for you
- Faster loading for distant visitors. Files travel a shorter distance, which reduces delay.
- Less load on your server. The CDN answers many requests so your host answers fewer.
- Extra protection. A properly set up CDN can also offer protection against some attacks, a firewall and certificate handling, according to Cloudflare.
What it can cost you
MDN lists the drawbacks, and they are worth reading:
- A new dependency. If the CDN fails, is blocked in a region or shuts down, your site may break.
- A new risk. A compromised CDN could serve harmful content.
- Sometimes slower. Connecting to another host adds lookups, and browsers do not share cached files between sites, so a file may be downloaded again.
A CDN is also one more service to set up, possibly pay for and fix when something goes wrong.
Is it different from caching on your server?
Yes. Server-side caching keeps ready-made pages on your own server so they are served quickly. Server Salad plans use LiteSpeed caching, as listed in what is included with every plan.
A CDN adds copies in many more places. You can use either, or both.
Does a small site need one?
Think about who visits and what they load.
- Mostly local visitors, light pages: you probably do not need a CDN. Fix the basics first, such as image sizes and the number of plugins.
- Visitors in several countries: a CDN may help, since distance matters more. Cloudflare says any site with a distributed audience can benefit, and that global sites see the largest gains.
- Large images or video: a CDN can take that load off your server.
- A shop with sudden spikes in traffic: a CDN can help absorb them.
If you are not sure, measure before you add one. Run your main pages through PageSpeed Insights, note the Core Web Vitals scores, add the CDN, and measure again. Our article on Core Web Vitals explains the scores.
Where your server is matters too
Our servers are in London. Distance from the server affects how quickly the first response arrives, which is one reason people ask about a CDN. We have not measured how much a CDN would help a Sri Lankan visitor, so test it for your own site and do not take it as a promise.
If you decide to add one
- Back up first. See why website backups matter.
- Start with static files such as images, styles and scripts.
- Check your SSL setup so that pages still load with the padlock. See what is SSL.
- Clear caches after changes, and test on a phone as well as a computer.
- Keep a way out. Know how to switch the CDN off if something breaks.
FAQ
Is a CDN the same as web hosting?
No. Hosting stores your site and runs it. A CDN keeps copies of files closer to visitors.
Is a CDN free?
Pricing varies by provider, so check the terms before you rely on one.
Will a CDN fix a slow site?
Only if distance or server load is the cause. Large images, too many plugins and slow code need their own fixes.
