Quick Summary
- A CDN is a worldwide network of caching edge servers (PoPs) that keep copies of your content close to users to cut latency
- A cache hit is served instantly from a nearby edge; a cache miss forces the edge to fetch from your origin server first, then cache it for next time
- TTL and cache-control headers decide how long a cached copy stays fresh, and CDNs shine for static content like images, CSS, JS, and video
The Neighborhood Bakery Analogy
Imagine there is exactly one bakery in the whole country, and every time anyone wants bread they have to drive across the nation to reach it. The bread would technically be available, but the trip would be slow, the roads would jam, and if that single bakery had a bad day, nobody anywhere could buy bread.
A CDN fixes this the obvious way: instead of one central bakery, it puts a fresh copy of the bread in a local shop on every street. Now you grab your loaf from around the corner. It is faster for you, the central bakery is no longer overwhelmed, and if one local shop closes, the others keep selling.
That is exactly what a Content Delivery Network does for websites. A CDN (Content Delivery Network) is a geographically distributed network of caching servers, called edge servers or Points of Presence (PoPs), that store copies of your content physically close to users. When someone visits your site, they are steered to a nearby edge rather than to your single distant origin server.
The goals are concrete: reduce latency (shorter physical distance means faster delivery), offload the origin server so it does less work, absorb sudden traffic spikes, and add resilience and DDoS protection by spreading load across many sites. Big-name CDNs include Cloudflare, Akamai, Fastly, and Amazon CloudFront.
Cache Hit vs Cache Miss
The single most important idea in a CDN is what happens when a request reaches an edge server. Either the edge already has the content (a hit) or it does not (a miss):
CDN Edge Map — Cache Hit vs Miss
Pick a user location. The request flies to the nearest edge. If that edge already cached the page it is a HIT; if not it is a MISS and the edge must fetch from the origin first. Clear the cache to make the next request cold again.
Latencies and distances are illustrative only — they show the pattern, not real-world measurements.
Notice the pattern from the edge map above: the first visitor to a region pays the price of a cache miss (the edge has to reach back to the origin), but every visitor after that enjoys a fast hit. This is the heart of how a CDN turns one slow origin into a fleet of fast local copies.
How a CDN Works, Step by Step
The User Is Steered to a Nearby Edge
When a user requests content, the CDN directs them to a nearby edge server rather than the distant origin. This steering is usually done with DNS-based routing (the DNS answer points to the closest PoP) or with anycast routing (the same IP is announced from many sites and the network delivers each user to the nearest one). Either way, the user does nothing special — they just get a fast answer from close by.
Hit or Miss at the Edge
The edge checks whether it already holds the requested content. A cache hit means it has the copy and serves it directly — fast, and the origin is never touched. A cache miss means it does not, so the edge fetches the content from the origin server, serves it to the user, and stores a copy locally. The next request for that same content from that region becomes a hit.
TTL Keeps Cached Copies Fresh
A cached copy cannot live forever, or users would see stale content. The origin sends cache-control headers with a TTL (time to live) that tells each edge how long the copy stays fresh. Once the TTL expires, the edge must revalidate with the origin before serving it again. Short TTLs mean fresher content but more origin trips; long TTLs mean fewer trips but slower updates.
Static Content Caches Best
CDNs are perfect for static content — images, CSS, JavaScript, video, and downloads — because that content is the same for everyone and can be reused. Dynamic or personalized content (like a logged-in dashboard) is cached less, or not at all, since it differs per user. Modern CDNs blur this line with edge compute, running small bits of logic at the edge, but the core rule holds: the more reusable the content, the more a CDN helps.
CDNs in the Real World
Here are three everyday situations where a CDN is quietly doing the heavy lifting:
Streaming Video
When you watch a show, the video chunks are served from an edge in your city, not from a single data center continents away. That is why playback starts quickly and rarely buffers — the bytes only travel a short distance. Popular titles stay warm in cache, so millions can watch at once without melting the origin.
Image-Heavy Websites
A news or shopping site loads dozens of images per page. With a CDN, those images, plus the CSS and JavaScript, are cached at edges worldwide. A reader in Sydney and a reader in Berlin each pull from a local PoP, so the page feels fast everywhere instead of only near the origin.
Surviving a Traffic Spike
When a product launch or viral post sends a flood of visitors, the CDN absorbs the surge across its many edges rather than letting it all slam the origin. The same spread-the-load design also helps blunt DDoS attacks, and the CDN can terminate TLS and filter bad traffic right at the edge.
Common CDN Mistakes
A misconfigured CDN can serve stale pages or accidentally cache private data. Watch out for these:
Forgetting to Purge After an Update
You deploy a fix, but users keep seeing the old version. That is because edges are still serving the cached copy until its TTL expires. After a content change you must invalidate or purge the old copies, or set sensible TTLs, so the edges revalidate and pick up the new content promptly.
Caching Personalized Content
If you cache a logged-in page, one user's account view can be served to a different user. Never cache
responses that are personalized or contain private data without scoping them by user. Mark such responses
as private or no-store so the CDN leaves them to the origin.
Thinking a CDN Replaces Your Host
A CDN is not a web host. It caches copies of content from your origin server, which still has to exist and generate the real pages. If your origin goes down and the cache expires, the CDN has nothing fresh to serve. Treat the CDN as an accelerator and shield in front of your host, not a substitute for it.
How Users Find the Nearest Edge
A CDN is only fast if each user actually reaches a nearby edge. Two techniques make that happen. With DNS-based steering, the CDN's DNS returns a different answer depending on where the query comes from, pointing each user at the closest PoP. With anycast routing, every PoP announces the same IP address over BGP, and the internet's routing naturally delivers each user to the topologically nearest site. Many CDNs combine both. The result is the same: you connect to the corner shop, not the central bakery.
Security at the Edge
Because a CDN already sits between users and your origin, it is a natural place to add security. CDNs commonly perform TLS termination at the edge (handling HTTPS handshakes close to the user for speed), filter malicious requests, rate-limit abusive clients, and absorb DDoS floods by spreading attack traffic across hundreds of sites instead of one. The same architecture that makes content fast also makes the origin harder to overwhelm.
The bottom line: a CDN is a worldwide fleet of caching edge servers that keep copies of your content close to users. Hits are served instantly from the edge; misses fetch from the origin once and then cache the result. Master the hit-versus-miss idea and TTL, and the rest of how CDNs make the web fast falls into place.
Frequently asked questions about CDNs
What is a CDN?
A CDN (Content Delivery Network) is a geographically distributed network of caching servers, called edge servers or Points of Presence (PoPs), that store copies of a website's content close to users. By serving content from a nearby location instead of one distant origin server, a CDN reduces latency, offloads the origin, absorbs traffic spikes, and adds resilience and DDoS protection.
How does a CDN make websites faster?
A CDN places copies of content on edge servers all around the world, so each user is served from a location that is physically close to them. Shorter physical distance means lower latency and faster load times. The CDN also terminates TLS at the edge and offloads work from the origin, so the site stays fast even under heavy load.
What is the difference between a cache hit and a cache miss?
A cache hit means the edge server already has a copy of the requested content and serves it directly to the user, which is fast and never touches the origin. A cache miss means the edge does not have the content, so it fetches it from the origin server, serves it to the user, and stores a copy so the next request for that content is a hit.
What is an origin server in a CDN?
The origin server is the authoritative source of truth that actually hosts your website or application. The CDN's edge servers cache copies of the origin's content. On a cache miss the edge fetches from the origin; on a cache hit it never has to. TTL and cache-control headers from the origin tell the edge how long a cached copy stays fresh before it must be revalidated.
What is the difference between a CDN and a web host?
A web host runs the origin server where your site truly lives, generating pages and storing the canonical files. A CDN sits in front of that host and caches copies of its content on edge servers worldwide to speed up delivery and add protection. A CDN does not replace a host; it accelerates and shields the host that already serves your content.
Build the network behind a CDN
A CDN is routing, DNS, and servers working together. Put a load balancer in front of your origin servers, point a DNS name at it, and trace a request by name all the way to the backend that answers. Caching and latency are not simulated, so the speed-up itself stays in the edge map above.
Launch the CDN origin lab →