CDN & Edge Caching

8.CDN & Edge Caching

M

In this chapter

We'll zoom out to CDNs and edge caching — the same real caching pattern from this whole Act, spread deliberately across physical distance so a customer's request is served from a nearby edge node instead of traveling all the way to GreenMart's own origin server.

7–9 min

The Problem in Real Life

GreenMart is expanding — real customers are now browsing from cities Mike has never shipped a single order to. "Someone in another country just told me the site feels slow," he says, "even after all this caching work."

Sarah nods. "Every fix so far assumed one server, in one place. That stops being enough the moment GreenMart's customers genuinely aren't."

M

Why would the site feel slow for someone far away, if the caching is already fixed?

Mike

One Cache, Far Away vs. Many Caches, Genuinely Close

Physical distance is a real, honest cost

Even at light speed, a long round-trip takes measurable time — a cost only physical proximity, not caching-in-place, can fix.

Edge nodes follow the same rules, closer to the customer

The same Cache-Control, TTL, and eviction logic from earlier chapters governs CDN edge nodes — just physically distributed.

CDN & Edge Caching

A CDN (content delivery network) is a real, geographically distributed network of servers — edge nodes — that each hold their own real cached copy of GreenMart's content, physically closer to wherever a real customer actually is. It's the same real caching pattern from this whole Act, deliberately spread across real physical distance instead of sitting in one place.

  • Why physical distance is a real, honest cost. Even at the real speed of light, data genuinely takes measurable time to travel a long physical distance — a request from a customer on the other side of the world to GreenMart's own single server, and the real response back, pays that real round-trip distance twice, no matter how fast the server itself responds. This is a cost caching-in-place can't fix at all; only physical proximity can.
  • Edge caching — the same idea, physically distributed. A CDN's real edge nodes each cache a copy of GreenMart's static content — product images, CSS, JavaScript — following the exact same real rules from this Act's earlier chapters (governed by the same Cache-Control headers, subject to the same real TTL and eviction logic) but physically located near real clusters of actual customers. A request from a nearby customer gets served from the closest edge node's own real cached copy, never traveling anywhere near GreenMart's own original server at all.
  • Origin vs. edge — a real, useful distinction. GreenMart's own actual server is the origin — the one real, authoritative source of truth. Every edge node's cache is, honestly, just another layer of the exact same caching hierarchy this whole Act has covered, one physical hop closer to a real customer, with the origin sitting at the very back, only reached on a genuine miss at every closer layer.
  • Not everything belongs on a CDN. Static, rarely-changing content (images, scripts, a product's own description) is a genuinely strong fit — cheap to distribute widely, and safe to cache for a real, long duration. GreenMart's own live stock count is the opposite case: personalized-feeling, changes constantly, and directly harmful when stale — exactly the kind of data this Act's earlier Cache-Control: private, no-store fix correctly kept off of every shared cache, CDN edge nodes included.

GreenMart now has the real, final layer of this Act's own caching hierarchy: not just what to cache and for how long, but genuinely where — physically — that cached copy should actually live, relative to the real customer asking for it.

Key Takeaway

A CDN is the exact same caching pattern from this whole Act, deliberately spread across real physical distance — edge nodes hold their own cached copies close to real customers, governed by the same Cache-Control rules, with the origin server as the one real source of truth behind all of them.

Why This Matters

As GreenMart genuinely grows beyond one region, physical distance becomes a real, measurable cost no amount of server-side optimization alone can fix. A CDN is the real, standard answer — and everything GreenMart already learned this Act about Cache-Control, TTL, and what should never be shared-cached applies directly to it.

GreenMart now understands caching as something that spans real physical geography, not just server memory. The next chapter covers a real, dramatic failure mode that can strike any of this Act's own caching layers at once: a cache stampede.

Next