← Lessons

quiz vs the machine

Silver1080

System Design

Content Delivery Networks

How putting copies of your content near users makes pages load fast across the globe.

3 min read · intro · beat Silver to climb

Distance is latency

A content delivery network, or CDN, is a fleet of servers spread across many locations that cache copies of your content close to users. Light and signals take time to travel, so a user far from your origin server waits longer. A CDN shortens that distance.

When a user requests a file, they are routed to a nearby edge server. If that edge already holds the file, it answers immediately. If not, it fetches once from the origin, caches it, and serves it.

What it is good for

  • Static assets like images, scripts, styles, and video.
  • Offloading the origin so it handles far fewer requests.
  • Absorbing spikes since the edge soaks up bursts of traffic.

Keeping content fresh

Cached content can go stale. CDNs use expiry times and invalidation to refresh files when they change, balancing freshness against the benefit of serving from cache.

Key idea

A CDN serves content from an edge near the user, cutting latency and shielding the origin.

Check yourself

Answer to earn rating on the learn ladder.

1. Why does a CDN reduce latency for distant users?

2. What happens on a cache miss at the edge?