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. 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. 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. 3

    Serve a cache hit

    If a fresh object is available, the CDN can return it from edge storage without contacting the origin.

  4. 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. 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. 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