CDN: content delivery network
A CDN (content delivery network) is a group of geographically distributed servers that store copies of your content and serve each visitor from the server nearest to them. It reduces latency and takes load off your own origin server.
- Content is copied to edge servers, and visitors are served from the nearest one.
- Closer servers mean lower latency, and fewer requests reach your origin.
- A CDN is also a dependency: if it fails or is blocked, your site can break.
What are the benefits and downsides of a CDN?
| Aspect | Effect |
|---|---|
| Request load | Lower. Static assets are served by the CDN, not your servers |
| Latency | Lower, because CDN servers are often geographically closer to users |
| Availability | A CDN outage, regional block or shutdown can make your site malfunction |
| Security | A compromised CDN could serve malicious content. Subresource Integrity helps |
| Performance cost | A third-party host adds DNS lookups and connections, and browsers do not share cache across sites |
See MDN: CDN.
How do you protect a CDN-hosted script?
<script src="https://cdn.example.com/library.min.js"
integrity="sha384-...base64-hash..."
crossorigin="anonymous"></script>What should you monitor when you use a CDN?
- The origin server directly, not only the CDN-fronted address
- The public site from several regions, since the edge answering you may differ by location
- Cache behavior: a stale or broken cached page can look healthy to the origin
- The certificate served at the edge, which may be separate from your origin certificate
Common questions
What does a CDN do?
A CDN stores copies of your static files, and sometimes whole pages, on servers in many locations. When a visitor requests a file, the nearest server answers instead of your origin. That cuts distance, lowers latency and reduces the load on your own server.
Do I need a CDN for a small website?
Not always. A site with a local audience and a fast host may gain little. A CDN helps most with global visitors, heavy static assets or traffic spikes. Many CDNs also add security features, which is a separate reason to use one.
Can a CDN cause downtime?
Yes. MDN lists dependence on a third party as a downside: if the CDN goes down, is blocked in a region or shuts down, your website may malfunction. Monitor the site through the CDN and the origin separately to tell which layer failed.
Sources
Keep reading
Watch your domains automatically
Aepto monitors expiry, DNS, SSL and uptime for every domain you own and alerts you when something changes. Free for 3 domains.