Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
DNS and Content Delivery Networks  ›  Lesson

Pull CDNs

Pull CDNs 12 minA pull CDN keeps nothing until asked: on the first request an edge server fetches the file from the origin, then serves cached copies until they expire.

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:

  1. A visitor in São Paulo asks the São Paulo edge for /logo.svg.
  2. Miss — the edge does not have it. It fetches from the origin, stores a copy, and returns it.
  3. The next visitors ask the same edge. Hit — served locally in milliseconds; the origin never hears about it.
  4. 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.

Hop's stylesheet through a pull CDNStep 1 of 4
  1. First visitor in São Paulo

    Miss. The edge fetches style.3b1c.css from 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.

quick drill

What does a pull CDN edge do on the first request for a file?

quick drill

Which Hop content is the worst fit for a CDN?

quick drill

What sets how long an edge keeps a copy?

quick drill

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.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainPut Hop's website behind a pull CDN

Hop's website (logo, stylesheet, scripts and a preview image for each popular link) is served from one server in Mumbai, and users in Brazil wait over a second per file. Explain how a pull CDN would change what happens for the first and the thousandth Brazilian visitor, and how Hop should release a new version of its stylesheet without users getting a stale copy.