systemdesign.academySystem Design MasterclassFree lessonsSign inGet the course
  1. Home

Where this shows up in interviews

6 system design questions lean on this idea. Each walks through the full answer.

  • →Design a News Aggregator
  • →Design Google Maps
  • →Design Instagram
  • →Design JioHotstar
  • →Design Netflix
  • →Design Pinterest
Previous lessonGlobal Server Load Balancing (GSLB)Next lessonLocal Cache

System Design

  • Foundation
  • Intermediate
  • Advanced
  • Capstone

AI Engineering

  • Foundation
  • Data, RAG and Agents
  • Evaluation, LLM Ops and Security

systemdesign.academy

  • Home
  • Glossary
  • Interview prep
  • Reviews
  • About
  • Privacy
  • Terms
System Design: Foundation
  • Load Balancing & Proxies
  • Content Delivery Network (CDN)
  • System Design Masterclass · Load Balancing Proxies

    Content Delivery Network (CDN)

    Free preview: the first 2 parts of this 10-part lesson.

    Already bought the course? Sign in to read the whole lesson.

    this lesson is part of

    System Design Masterclass

    Unlock this lesson and the 751 other paid lessons

    • 770 lessons, beginner to principal
    • 90 real interview systems taken apart step by step
    • An AI tutor beside every lesson that answers and draws
    • Lifetime access, every new lesson included

    $49 once, by PayPal

    See the System Design course

    The rest of this lesson

    1. Asking Four Real CDNs
    2. The Measurement Was Wrong Twice First
    3. The Interface Is Six Headers
    4. The Incident That Keeps Happening
    5. The Number on the Dashboard Is the Wrong One
    6. Cold Caches and Changing Your Mind
    7. Deciding, Debugging, Defaults
    8. Quick Check

    read the rest of this lesson in

    System Design Masterclass

    Unlock this lesson and the 751 other paid lessons

    • 770 lessons, beginner to principal
    • 90 real interview systems taken apart step by step
    • An AI tutor beside every lesson that answers and draws
    • Lifetime access, every new lesson included

    $49 once, by PayPal

    See the System Design course

    Continue this lesson

    in Load Balancing Proxies

    This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.

    One-time payment. Lifetime access. No subscription.
    Global
    $49/lifetime

    One-time payment via PayPal

    Get Lifetime Access
    Foundation lessons free, try before you buy
    India Special
    India
    ₹499/lifetime

    One-time payment via UPI

    Get Lifetime Access
    Foundation lessons free, try before you buy
    All 770 interactive lessons
    Step-by-step animated diagrams
    Runnable code in the lessons where code helps
    Quizzes with instant feedback
    Lifetime access, all future content included

    18 Foundation lessons are free, no payment needed. Try them now

    A Cache You Do Not Operate

    The previous lesson ended with a mechanism whose behaviour was decided by resolvers nobody in your company controls. This one is the same shape again, with the stakes moved from routing to content.

    Two panels. The left, origin only, shows a user in Sydney making one long trip to your origin in Virginia. Its key reads: every request crosses an ocean, origin sees 100 percent of traffic, you control all of it. The right, with a CDN, shows the same user reaching a nearby edge, with the origin contacted only on a miss. Its key reads: most requests stop at the edge, origin sees the misses only, you control the rules and not it.
    ComparisonFigure 1. The distance shrinks, and so does how much of your own system you can see

    A is a cache in front of your origin, run by somebody else, in thousands of places at once. Both halves of that sentence matter. The first half is why people buy one. The second half is where all the difficulty comes from.

    A sequence diagram with three lifelines: the user, the nearest edge and your origin. The user requests app.css, the first time anyone in that city asked. The edge has no copy so it fetches one, noted as this request being slower than having no CDN at all. The origin returns 200 with a Cache-Control header. The edge answers the user and keeps a copy. The next user in that city requests the same file and is answered from the copy, with the origin never contacted, noted as this is the whole product.
    SequenceFigure 2. The first request is slower than no CDN, and every one after it is faster

    A miss adds a hop, so the first user waits for both legs of the journey. The economics only work because misses are rare, and misses are only rare if the cache key is right.

    That last sentence is the whole lesson.

    The Cache Key Decides Everything

    Four hand-drawn boxes joined by plus signs: host, path, query and some headers. Underneath, host and path are labelled always, query is labelled usually but not always and is highlighted, and some headers is labelled if Vary says so. A handwritten red note reads: get this wrong and one object becomes a million uncached ones.
    SketchFigure 3. What the edge thinks makes two requests the same request

    Two requests with the same key share one stored copy. Two requests with different keys are two separate objects, even when the bytes are byte for byte identical. Nothing here is about your content, and everything is about what the edge decides it may reuse.

    A cache key that is too broad serves the wrong content to somebody. A cache key that is too narrow serves the right content and stores a separate copy for every visitor, which is a cache that never hits. The second failure is far more common and much harder to notice, because nothing breaks.

    Every write-up of this subject states the same rule: the query string is part of the cache key, so appending a tracking parameter fragments your cache. It is a good story with a clear villain. It was also worth checking.