Pull CDNs
Hop's website lives on one server in Mumbai. A visitor in São Paulo waits over a second for each file, because every byte crosses the planet. Faster code cannot beat the speed of light. The fix is to keep copies of the files near the visitors — that is what a content delivery network (CDN) does.
The rule
The edge fetches on the first miss, then serves its copy until it expires.
A CDN is a network of edge servers in many cities. DNS or network routing sends each user to a nearby edge. The edge keeps copies of content from your origin server (Hop in Mumbai).
With a pull CDN, you upload nothing ahead of time. The edge pulls content only when someone asks:
- A visitor in São Paulo asks the São Paulo edge for
/logo.svg. - Miss — the edge does not have it. It fetches from the origin, stores a copy, and returns it.
- The next visitors ask the same edge. Hit — served locally in milliseconds; the origin never hears about it.
- The copy lives for its cache time, set by the origin with a header like
Cache-Control: max-age=86400. After that, the edge checks the origin again.
What suits a CDN: images, stylesheets, scripts, videos, downloads — files that are the same for every visitor. Hop's personal dashboard, which differs per user, does not.
Pull CDNs are low-effort: point the CDN at your origin and it fills itself with whatever is actually popular. The costs are a slow first request at each edge, and copies that can be stale until their cache time ends.
The shortcut
To change a cached file, change its name, don't wait for expiry. Publish style.4f2a.css instead of overwriting style.css; the page points at the new name, and every edge misses and fetches it fresh.
First visitor in São Paulo
Miss. The edge fetches
style.3b1c.cssfrom Mumbai (about 1 s), stores it and serves it.
The trap is overwriting a file under the same name and wondering why half the world still sees the old one for a day.
Drills
Answer fast — trust the rule.
What does a pull CDN edge do on the first request for a file?
Which Hop content is the worst fit for a CDN?
What sets how long an edge keeps a copy?
Hop changes its logo but users still see the old one. What is the cleanest fix for next time?
Remember
- The edge fetches on the first miss, then serves its copy until it expires.
- Shortcut: to change a cached file, change its name.
- Trap: overwriting a file under the same name and waiting a day for caches to notice.
