DNSAage 0 sBC✕DOWNGETGETGETGETGETGETGETGETGETGET
Sky blocks: the CDN's edge sites A, B, C, one anycast addressTall block: the origin serverGolden tile: site A's cached copy of the fileTeal: your provider's router, which picks the nearest siteWithout a CDN every visitor fetches www.example.com from the far origin 198.51.100.20. A CDN keeps copies on edge sites near people, and DNS or anycast steers each visitor to a nearby one. With anycast, sites A, B and C all announce 203.0.113.0/24 with BGP and answer on 203.0.113.50; routers pick the shortest path, so you reach site A and your friend site C. Site A misses once, fetches from the origin and keeps the copy for max-age 3600 s, then hits; a stale copy is revalidated with If-None-Match and 304 Not Modified. When site C fails, it withdraws its route and your friend reaches site B.

Why a CDN

  1. Without help, every visitor fetches the website from its origin server, the site's own computer. If it is far away, each round trip is slow, and the origin must answer every visitor in the world by itself.

Finding a nearby edge

Hits, misses and max-age

When a site fails

The messages, step by step

;; step 1/11 · far
;; you → origin
GET /logo.png  Host: www.example.com
you → 198.51.100.20 (the origin)
round trip ≈ 180 ms (illustrative: far away, many hops)
a page with 40 files may need many round trips
and every request in the world lands on this one server

Illustrative numbers: round trips of 180 ms to the origin and 12 ms to a nearby edge, a DNS TTL of 60 s and a max-age of 3600 s. Real values depend on the site and the CDN. 203.0.113.0/24, 203.0.113.50, 198.51.100.20 and the site addresses 192.0.2.10, 192.0.2.20, 192.0.2.30 are RFC 5737 documentation addresses; AS64496 and AS64500 to AS64502 are RFC 5398 documentation AS numbers. www.example.com is reserved by RFC 2606.