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.