CDNs and anycast
Big websites feel fast everywhere because they are not served from one place. Follow one file, www.example.com/logo.png, as a CDN keeps copies on edge sites near people, DNS or anycast steers you to a nearby site, a cache misses once and then hits, max-age decides how long a copy stays fresh, and a failed site quietly hands its visitors to the next one.
5 quick questions
Pick an answer to see why. Your score saves with your progress.
01What does a CDN edge server keep?
The origin still holds the real site. Edges are caches near people: they answer from their copies when they can, which is faster for visitors and less work for the origin.
02Sites A, B and C all announce 203.0.113.0/24 and answer on 203.0.113.50. You send a packet to 203.0.113.50. Which site gets it?
That is anycast (RFC 4786): one address, many sites. Ordinary routing delivers each packet to one site, the nearest in routing terms, so you and a friend in another city reach different sites with the same address.
03Site A is asked for /logo.png but has no copy yet. What happens?
The first request for a file at an edge is a miss and costs an extra trip to the origin. Later requests for the same fresh file are hits, answered from the stored copy.
04The origin sent the file with Cache-Control: max-age=3600. The copy at site A is now 3610 seconds old. What does site A do?
max-age=3600 means fresh for one hour (RFC 9111). Once older, the copy is stale and is checked with a conditional request. 304 Not Modified carries no file, just "your copy is still good".
05Site C fails and withdraws its route. What does your friend, who was using site C, need to do?
With anycast, the address stays the same. When site C stops announcing the block, BGP routers fall back to the next best path, here site B. A connection that was open at that moment may break and be retried.
Glossary
- CDN
- Content delivery network: many edge servers in different places that keep copies of websites' files close to visitors.
- Origin server
- The website's own server, which holds the real files; edges fetch from it when they miss.
- Edge server
- A CDN server near visitors that answers requests from its cached copies.
- Anycast
- Announcing the same address from many sites, so routing delivers each packet to the nearest one (RFC 4786).
- BGP
- Border Gateway Protocol: how networks tell each other which address blocks they can reach, and withdraw them.
- Cache hit / miss
- A hit is answered from a stored copy; a miss has to fetch the file from the origin first.
- max-age
- A Cache-Control value: how many seconds a stored copy stays fresh (RFC 9111).
- 304 Not Modified
- An HTTP answer meaning the stored copy is still current, sent with no file attached.
Notes and sources
- 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.
- Anycast "nearest" is nearest in routing terms: BGP compares policy and AS path length, not distance on a map, so a visitor can now and then land on a site that is not the closest in kilometres (RFC 4786, RFC 7094).
- Real CDNs mix both methods: many use anycast for their DNS servers and some for their edges, while others steer with DNS to per-site addresses. The DNS root servers are a famous anycast service.
- max-age, Age, ETag, If-None-Match and 304 Not Modified are defined in RFC 9111 and RFC 9110. A file marked private or no-store is not kept by a shared cache such as a CDN edge.
Quiz Unlocks after the last step.