CDN
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Content delivery network (CDN): the 60-second story

    CDN

    Not one dairy gate, but a milk booth on every street.

    You walk two minutes, and the dairy sends one van per booth. For paneer, fifty booths ask one depot, which places a single order.

    660 ms

    before the first byte, Chennai to Virginia

    TCP, TLS and the request each cost a 220 ms round trip. From an edge 10 ms away, a hit takes 30 ms; a miss, 250.

    Four points of hit ratio, five times the origin.

    At 100,000 requests a second, 95% hits send 5,000 to the origin and 99% send 1,000. Bytes, which are the bill, follow the same rule.

    Tiers turn hundreds of misses into one origin fetch.

    Edges keep what’s locally popular, a regional tier keeps the long tail, and an origin shield merges concurrent misses. Each miss pays one extra hop.

    Does no-cache mean don’t cache?

    Bad: no-cache = don’t store

    So personal pages get no-cache, and everyone feels safe.

    Good: no-cache = check first

    It stores, then revalidates before each reuse. Only private or no-store keeps it out.

    You deploy new JavaScript and purge every PoP. Phones still run the old file.

    The trick

    Fingerprint it: app.3f9a1c.js, cached a year with immutable. A new build is a new name; only HTML stays short.

    The cache key decides who shares a copy.

    Key on Accept-Language and one English page becomes four copies. Leave out what changes the response, and one visitor’s page goes to everyone.

    The CDN is a dependency too

    1. Fastly, June 2021: 85% of its network erred
    2. Multi-CDN, or a tested runbook to the origin
    3. Bypassing a 99% CDN sends the origin 100×

    Remember

    A CDN puts caches near users, so hits take milliseconds and the origin sees only misses. Fingerprint assets for a year, keep HTML short, never cache the private, and lock the origin to the CDN.