What is a CDN? A plain explanation
Why web pages load fast everywhere: how content delivery networks cache files at the edge, route visitors to the nearest server, and protect sites from attacks.
On this page
- The problem CDNs solve
- How a CDN works
- What a CDN caches
- Why sites use a CDN
- CDNs and DNS
- Who runs CDNs
- FAQ
- What is the difference between a cache hit and a cache miss?
- Can a CDN cache dynamic content like personalized pages?
- How does a CDN make my website faster and cheaper to run?
- How does a CDN protect a site from attacks?
- Summary
A content delivery network (CDN) is a geographically distributed network of servers that delivers web content by caching it close to users. Instead of every visitor downloading files from your single origin server, most of them are served from a nearby edge server — which is why a site on a CDN feels fast on every continent.
The problem CDNs solve
In the early internet, content lived on one server in one city. A visitor on the other side of the planet had to cross many network hops to reach it, and the server had to answer every request itself. As the internet grew in the late 1990s, this became a performance bottleneck, and the first CDNs appeared to fix it.
Today, a large portion of internet content — text, images, video, software downloads — is delivered through CDNs.
How a CDN works
A CDN is a network of servers linked together, with the goal of delivering content as quickly, cheaply and reliably as possible. The pieces:
- Origin server — the "source of truth", the server that holds the original copy of your site or app.
- Edge servers — thousands of cache servers placed around the world, often in data centers called points of presence (PoPs).
- Routing — when a visitor requests your site, the CDN connects them to the nearest edge location.
What happens on a typical request:
- Your browser asks for a file — an image, a stylesheet, a page.
- The nearest edge server checks its cache. If it has the file, that is a cache hit: the answer comes back in milliseconds, and the origin server is never contacted.
- On a cache miss the edge fetches the file from the origin, stores a copy, and serves it.
- The next visitor who asks for the same file gets the cached copy.
The origin only sees requests it cannot avoid — which dramatically reduces its load.
What a CDN caches
Caching works because most web content is static: it does not change for every visitor. Files are stored at the edge for a limited time, controlled by HTTP caching rules (for example Cache-Control headers and a TTL). When the copy expires, the next request refreshes it from the origin.
Dynamic content — personalized pages, shopping carts — is harder to cache. CDNs handle it by passing it through to the origin, or by running code at the edge that builds the response there.
Why sites use a CDN
- Speed — files travel a shorter distance, so pages load faster, which also helps search rankings and conversion.
- Availability — if one data center or the origin fails, traffic is rerouted to other edge locations; the site keeps working.
- Resilience and security — CDNs absorb large traffic spikes, mitigate DDoS attacks, and often manage TLS certificates and a web application firewall (WAF).
- Cost — the origin serves fewer requests, so origin bandwidth and infrastructure costs drop.
CDNs and DNS
A CDN relies on DNS to do its job. When your browser resolves your domain, the CDN's DNS answers with the address of the edge server that is best for your location. This happens on every connection, so the same domain can point to different servers for different visitors — while the domain itself never changes.
Who runs CDNs
Most large websites use a CDN, and the providers are household names in tech: Akamai, Cloudflare, Fastly, Amazon CloudFront and Google Cloud CDN, among others. Hosting platforms often include a CDN by default — this site, for example, is served through the Cloudflare network.
FAQ
What is the difference between a cache hit and a cache miss?
A cache hit happens when the nearest edge server already has the requested file, so the answer comes back in milliseconds and the origin server is never contacted. A cache miss means the file is not at the edge, so the server fetches it from the origin, stores a copy, and serves it — the next visitor asking for the same file gets the cached copy.
Can a CDN cache dynamic content like personalized pages?
Dynamic content — personalized pages, shopping carts — is harder to cache because it changes per visitor. CDNs handle it by passing it through to the origin, or by running code at the edge that builds the response there. Static content, controlled by HTTP caching rules like Cache-Control and a TTL, is what gets stored at the edge for a limited time.
How does a CDN make my website faster and cheaper to run?
Files travel a shorter distance because most visitors are served from a nearby edge server, so pages load faster. At the same time the origin only sees requests it cannot avoid, which dramatically reduces its load — fewer requests means lower origin bandwidth and infrastructure costs.
How does a CDN protect a site from attacks?
CDNs absorb large traffic spikes and mitigate DDoS attacks by spreading requests across thousands of edge servers around the world, so no single server is overwhelmed. They also often manage TLS certificates and a web application firewall (WAF).
Summary
A CDN is a world-wide network of caching servers that brings content closer to visitors. It makes sites faster and cheaper to run, and it protects them from traffic spikes and attacks. When a site "loads fast everywhere", a CDN is usually the reason.
Sources
- Cloudflare Learning Center — What is a CDN? (cloudflare.com/learning/cdn/what-is-a-cdn)
- Wikipedia — Content delivery network (en.wikipedia.org/wiki/Content_delivery_network)
Share this guide
Related guides
- How DNS works: a plain explanation
What happens when you type a web address? A simple walkthrough of DNS — domain hierarchy, resolvers, caching and TTL.
- What is a proxy server and how does it work?
A plain explanation of proxy servers — forward vs reverse, what they do, the headers they add, and what they cannot protect.
- What is HTTP/3? A plain explanation
The newest version of HTTP runs on QUIC, a transport built on UDP instead of TCP. Here's what changes — and why pages feel faster with it.