learn/System Design/Content Delivery Network
PerformanceIntermediate interactive

Content Delivery Network

Serve content from a location close to the user.

cdn
client
edge
origin

Click 'request asset' to fetch /logo.png.

speed1×

How it works

A CDN is a globally distributed network of edge servers that cache content closer to users, so requests don't have to cross the world to the origin. Push CDNs are pre-loaded with content ahead of time; pull CDNs fetch and cache lazily on first request, trading a slower first hit for far simpler operations.

Mental models

  • Two wins at once: users get content from a nearby edge, and your origin serves fewer requests overall.
  • Push CDNs: you upload content ahead of time — a good fit for small or rarely-updated sites.
  • Pull CDNs: the edge fetches on first request and caches it for the TTL — better for heavy or long-tail traffic, since only what's actually requested gets stored.
  • DNS resolution is what routes a client to its nearest edge in the first place.
  • Static assets (HTML/CSS/JS, images, video) are the classic fit; some CDNs also front dynamic content.

Common pitfalls

  • A pull CDN's first request per edge is a full origin round trip — a cold edge is exactly as slow as no CDN at all.
  • Content can go stale if it changes before the TTL expires — cache invalidation costs real money and complexity (versioned URLs help).
  • Every static asset URL now points at the CDN — swapping providers later means rewriting URLs everywhere.

Reach for it when

  • Static asset delivery at global scale
  • Video / image-heavy sites
  • Offloading origin servers from read traffic