Web infrastructure
How does a CDN work?
A content delivery network serves cacheable content from edge locations closer to users. The edge can answer immediately on a cache hit or fetch the object from an origin on a miss, then reuse it according to cache-control rules.
Step-by-step
- 1
Route toward an edge
DNS, Anycast, or provider-specific routing steers the request to a suitable CDN point of presence. The exact mechanism varies by CDN.
- 2
Inspect the edge cache
The edge evaluates the cache key and cache policy to determine whether a usable response is already stored locally.
- 3
Serve a cache hit
If a fresh object is available, the CDN can return it from edge storage without contacting the origin.
- 4
Fetch on a miss
When the object is absent, stale, or not cacheable, the edge requests it from the origin or another upstream cache tier.
- 5
Store according to policy
Cacheable origin responses can be stored with TTL, validation metadata, and key variations derived from headers or provider rules.
- 6
Deliver from the edge
The edge returns the response to the user and can serve subsequent matching requests until the object expires, is purged, or must be revalidated.
Keep learning
Related visual explainers
How does Redis caching work?
A Redis cache keeps frequently requested data in fast in-memory storage so an application can avoid repeating slower database or service work. A common cache-aside flow checks Redis first, falls back to the source on a miss, then stores the result with an expiration policy.
What happens when you enter a URL?
Opening a URL triggers a chain of work across the browser, DNS, network transport, TLS, HTTP, edge or origin servers, and finally the browser's rendering pipeline. Modern stacks can vary, but the core stages remain recognizable.