What a CDN does
A content delivery network is a fleet of edge servers spread across the world. It caches content close to users, so a request is served from a nearby edge rather than the distant origin. This cuts latency and shields the origin from load.
How edge caching works
- On an edge miss, the edge fetches from the origin, caches the response, and serves it.
- Later requests in that region hit the edge directly.
- Cache behavior is driven by HTTP headers like cache control and the TTL they set.
Controlling freshness
- Cache control headers set max age and whether a response is cacheable.
- Purge or invalidation APIs remove stale objects from every edge when content changes.
- Versioned URLs, where a new asset gets a new path, sidestep invalidation entirely since the new URL is simply a new key.
Best fits
CDNs excel at static assets like images, scripts, and video, and increasingly cache cacheable API and HTML responses too. Highly personal or rapidly changing data is a poor fit.
Key idea
A CDN caches content at edges near users to slash latency and origin load, governed by HTTP headers with purges or versioned URLs for freshness.