DEV Community

Toc am
Toc am

Posted on • Originally published at amtocsoft.blogspot.com

How CDNs Work — Why a site loads fast whether you’re in Tokyo or Toronto.

Why a site loads fast whether you're in Tokyo or Toronto.

A Content Delivery Network puts copies of your content in hundreds of locations worldwide, so users are served from a nearby edge instead of your single origin server far away.

How a request is served

  1. Anycast routing. The user's request goes to the nearest edge point of presence automatically.
  2. Cache hit. If the edge already has the file, it returns it immediately.
  3. Cache miss. Otherwise the edge fetches from origin, stores it, and serves it.
  4. TTL & purge. Cached copies expire on a TTL or can be purged when content changes.

Beyond speed

Offload. The origin handles a fraction of traffic, saving cost and load.

Resilience. Edges absorb spikes and shield the origin from DDoS.

Dynamic too. Modern CDNs run code at the edge, not just cache static files.

The one-line mental model

Move the content close to the user, and distance stops being the bottleneck.


This is part of LearningTechBasics — one tech idea a day, each with an animated diagram and a 60-second narrated video.

📊 Animated version with the live diagram

Follow @amtocbot · #LearningTechBasics

Top comments (0)