An edge near the user — hit and miss — per-region caching that cuts origin RPS

An edge caches origin's response so the FIRST request in a region pays the full RTT but every later request in that region is served locally in milliseconds — and origin only hears about misses.

Previously

One origin can't be close to everyone — so we put a copy of the content near each user, and now the question is whether having a copy nearby is enough to make every request fast.

Scene 02

An edge near the user — hit and miss

  1. Watch
  2. Try it
  3. Predict
  4. Capture
WITH CDNORIGINus-eastEDGESydney(empty)HIT 0MISS 0usruser · SydneyEDGEFrankfurt(empty)HIT 0MISS 0usruser · Frankf…EDGESão Paulo(empty)HIT 0MISS 0usruser · São Pa…ORIGIN RPS0 / 12per-region p50 — short bars mean the edge is doing its jobSydney0 µsFrankfurt0 µsSão Paulo0 µsfirst request in each region pays the long ocean trip; every subsequent request in that region is a local HIT.
What to watch for

Each region's first request goes all the way to origin (long orange arrow) and the local cache slot fills green. Subsequent requests in the same region come back fast from the edge — the latency strip drops from ~200 ms to ~10 ms.

Continue unlocks when the animation finishes.
Implementation

Highlighted lines are the ones running in the diagram right now.

Edge.handle
the request handler running on every edge POP
def handle(req):
key = cacheKey(req) # URL + Vary axes
entry = self.cache.lookup(key)
if entry is not None:
return entry.body # HIT — served locally
# MISS — origin is the only source
body = origin.fetch(req.url)
self.cache.store(key, body)
return body
EdgeCache.lookup
the cache slot is per-edge — no peer consultation
def lookup(key):
# self.slots lives in THIS POP's RAM/SSD only.
# Sibling edges in other regions are never queried.
entry = self.slots.get(key)
if entry is None:
return None # caller must go to origin
return entry
def store(key, body):
self.slots[key] = Entry(body)

Where this sits in Build a CDN

Scene 02 of 13, in the Edge basics act — The request journey, origin pain, an edge near each user, POPs and anycast.. An edge cache absorbs the second request in each region; the first still pays the full RTT, and edges don't share content across regions.

Up next. Edges only help if users actually land on a nearby one — so how does a user in Sydney find Sydney's edge in the first place?

All 13 scenes in Build a CDN · Every curriculum

Built with Arqly
Every scene in Build a CDN builds on the one before it.All 13 Build a CDN scenes