{"post":{"slug":"cdns-explained-2026","title":"CDNs explained in 2026: how content delivery networks actually work","excerpt":"CDNs have evolved far beyond static file caching — they now run code at the edge and shape latency for every layer of your stack. Here is what matters in 2026.","category":"code","date":"February 20, 2026","author":"ByteLedger Team","content":"<span class=\"dropcap\">A</span> CDN is infrastructure that puts copies of your content physically closer to the user requesting it. The global internet is fast, but physics caps it: every 100 km of fiber adds roughly 0.5 ms of round-trip latency. A user in Tokyo fetching assets from a Virginia origin faces 150–200 ms just in transit. A CDN edge node in Tokyo cuts that to 5–15 ms. That difference is measurable in conversion rates.\n\n## What changed in 2026\n\n- **Edge compute became the default.** Every major CDN now runs a V8-isolate or WASM runtime at the edge. Cloudflare Workers, Fastly Compute@Edge, and Vercel/Netlify Edge Functions let you execute logic — auth, A/B, personalization — before requests ever reach your origin.\n- **HTTP/3 (QUIC) is universal.** All tier-1 CDNs speak QUIC to browsers and increasingly QUIC back to origins, eliminating head-of-line blocking and improving performance on lossy networks.\n- **AI inference moved to the edge.** Lightweight models (< 7B parameters, quantized) run inside CDN PoPs to handle classification and moderation without a round-trip to a GPU cluster.\n- **Private CDN topologies emerged.** Large teams now build tiered CDN meshes: a public CDN layer, a regional mid-tier, and an internal origin shield — all from the same control plane.\n\n## Core concepts\n\n**Point of Presence (PoP).** A PoP is a CDN datacenter in a specific city. Major providers operate 200–600 PoPs globally. When a user makes a request, DNS or Anycast routing directs them to the nearest PoP.\n\n**Cache hit vs miss.** On a hit, the PoP serves the stored response. On a miss, the PoP fetches from origin, stores the response, then serves it. Subsequent requests for the same resource hit the cache.\n\n**Cache-Control.** The origin sets this header to tell the CDN (and browser) how long to cache a response.\n\n```http\nCache-Control: public, max-age=86400, s-maxage=31536000, stale-while-revalidate=3600\n```\n\n`s-maxage` overrides `max-age` for shared caches (CDN). `stale-while-revalidate` lets the CDN serve a stale copy while fetching a fresh one in the background — reducing perceived latency to zero on popular assets.\n\n**Vary header.** Tells the CDN which request headers affect the response, creating separate cache buckets per variant.\n\n```http\nVary: Accept-Encoding, Accept-Language\n```\n\nGetting `Vary` wrong means either serving gzipped HTML to clients that can not decompress, or creating so many cache variants that your hit rate collapses.\n\n## What changed in 2026\n\n| CDN capability | Pre-2023 | 2026 |\n| --- | --- | --- |\n| Edge compute | Limited (Lambda@Edge only) | First-class (Workers, Compute@Edge, Edge Functions) |\n| Protocol | HTTP/2 dominant | HTTP/3/QUIC universal |\n| Cache purge latency | 30–120 s | < 1 s (tag-based, instant) |\n| Origin protocol | HTTP/1.1 or HTTP/2 | HTTP/3 back-haul supported |\n| AI at edge | None | Inference for small models |\n\n## How origin shield works\n\nWithout a shield, every PoP in the network can independently cache-miss back to your origin. If you have 400 PoPs and a cold cache, you can get 400 simultaneous origin requests for the same resource — a \"thundering herd.\"\n\nAn origin shield inserts a single PoP as the \"last line of defense\" before your origin. All other PoPs miss to the shield first; only the shield misses to origin.\n\n```\nBrowser → Edge PoP (miss) → Shield PoP (miss) → Origin\n                          ↑\n               (all other PoPs miss here)\n```\n\nIn practice this reduces origin request volume by 80–95% for popular content.\n\n## Edge compute patterns\n\n```typescript\n// Cloudflare Worker: A/B test at the edge\nexport default {\n  async fetch(request: Request): Promise<Response> {\n    const bucket = Math.random() < 0.5 ? \"a\" : \"b\";\n    const url = new URL(request.url);\n    url.hostname = bucket === \"a\" ? \"origin-a.example.com\" : \"origin-b.example.com\";\n    return fetch(url.toString(), request);\n  },\n};\n```\n\nThis worker runs in < 1 ms at the nearest PoP, adding zero perceptible latency while splitting traffic.\n\n## How to pick a CDN\n\n| Requirement | Recommended approach |\n| --- | --- |\n| Static site, low traffic | Cloudflare Free / Vercel built-in |\n| API with auth at edge | Cloudflare Workers or Fastly Compute |\n| Large media / video | AWS CloudFront or Akamai |\n| Enterprise SLA + support | Akamai, Fastly, or AWS CloudFront |\n| Edge AI inference | Cloudflare AI Gateway (2025+) |\n\n1. **Know your traffic pattern.** Static-heavy sites benefit most from aggressive max-age. APIs with per-user responses often get 0% cache hit rate unless you architect for it.\n2. **Set `s-maxage` and `stale-while-revalidate` on every cacheable route.** Defaults (no caching) are the most common misconfiguration.\n3. **Use cache tags / surrogate keys** for instant targeted purging. Purging by URL path is slow and error-prone.\n4. **Enable origin shield** from day one; it costs little and saves your origin on every traffic spike.\n\n## Common mistakes\n\n**No Cache-Control on API responses.** Public API endpoints that do not change per user (country lists, config, product catalog) can cache for minutes — but most teams leave them `no-store` by default.\n\n**Ignoring `Vary`.** If you gzip responses but do not `Vary: Accept-Encoding`, some CDNs serve the raw body to clients expecting gzip.\n\n**Caching HTML with a long TTL.** HTML is usually personalized or changes with deployments. Use a short TTL (60–300 s) or rely on cache tags for instant purge.\n\n**Over-relying on purge.** Purge is a reactive fix. Set TTLs that match your actual change cadence so purge is rarely needed.\n\n**Not measuring hit rate.** You can not optimize what you do not measure. Every major CDN exposes cache hit ratio in its analytics — check it weekly.\n\n## What to skip\n\n- **Building your own CDN** — unless you are at Netflix / Cloudflare scale, the economics are brutal.\n- **Disabling the CDN for staging** — you need to test caching behavior before it hits production.\n- **Cache everything including auth-required pages** — leaking private data via CDN cache is a serious security incident.\n\n## FAQ\n\n**Do CDNs work for APIs or just static files?**\nYes, APIs can cache heavily if responses are public and reasonably stable. Add `Cache-Control: public, s-maxage=60` to endpoints like `/api/products` and cache hit rates often jump past 80%.\n\n**What is the difference between a CDN and a reverse proxy?**\nA reverse proxy (e.g., Nginx) typically sits in one location in front of your origin. A CDN distributes that proxy globally across dozens or hundreds of PoPs.\n\n**How do I purge the cache after a deployment?**\nUse cache tag purging: tag all assets with a deployment ID, then purge that tag on deploy. Most CDNs support this via API in < 1 s globally.\n\n**Does HTTP/3 change how I configure my CDN?**\nMostly not from a config standpoint — your CDN enables QUIC for you. Ensure you are not blocking UDP port 443 at your firewall, which QUIC requires.\n\n## Where to go next\n\n- [Reverse proxies explained in 2026](/blog/reverse-proxies-explained-2026)\n- [DNS explained in 2026](/blog/dns-explained-2026)\n- [Load balancers explained in 2026](/blog/load-balancers-explained-2026)","hue":309,"metaTitle":"CDNs Explained in 2026: How Content Delivery Networks Work","metaDescription":"Plain-language guide to CDNs in 2026. How PoPs, edge compute, Cache-Control, and origin shields work together to cut latency and protect your origin.","keywords":["cdns explained 2026","content delivery network 2026","how cdn works","edge computing cdn","cdn cache control headers","cloudflare cdn 2026","cdn origin shield","cdn latency reduction","edge functions explained","cdn best practices 2026"],"tldr":["**A CDN puts copies of your content closer to users** — reducing round-trip distance from ~100 ms to ~10 ms for cached responses.","**Modern CDNs run serverless compute at the edge** — Cloudflare Workers, Fastly Compute, and Vercel Edge Functions execute code in 300+ PoPs worldwide.","**Cache-Control headers are still your primary lever** — a wrong max-age directive wrecks both freshness and origin load simultaneously.","**Origin shield / tiered caching cuts origin traffic 80–95%** on most workloads once tuned correctly.","**Skip:** routing all requests through your CDN without setting proper Vary headers — you will serve wrong cache variants to different user agents."],"readTime":"5 min read","wordCount":1157},"related":[{"slug":"middleware-explained-2026","title":"Middleware explained in 2026: how request pipelines actually work","excerpt":"Middleware is the chain of functions between a request arriving and your route handler running. In 2026 it spans HTTP servers, message brokers, and AI inference pipelines.","category":"code","date":"March 19, 2026","author":"ByteLedger Team","readTime":"5 min read","hue":318},{"slug":"what-is-a-cdn-2026","title":"What is a CDN in 2026? Content delivery networks explained","excerpt":"A CDN is a network of servers spread worldwide that store copies of your files near users. Here is how it works, why it speeds up sites, and when you need one.","category":"code","date":"May 13, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":205},{"slug":"edge-functions-explained-2026","title":"Edge Functions Explained in 2026: What They Are and Limits","excerpt":"Edge functions run inside V8 isolates or Wasm sandboxes across dozens of global locations, trading full runtime compatibility for sub-millisecond cold starts. Here is what they are actually good for.","category":"code","date":"August 1, 2026","author":"ByteLedger Team","readTime":"4 min read","hue":308}],"sameCategory":[{"slug":"bazel-build-explained-2026","title":"Bazel Explained: What Hermetic Builds Actually Cost","excerpt":"Bazel delivers reproducible, precisely cached builds and demands that you describe everything. Here is what you get, what it costs, and who should say no.","category":"code","date":"August 19, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":145},{"slug":"graphql-federation-2026","title":"GraphQL Federation: One Graph, Many Teams","excerpt":"Federation composes independently-owned subgraphs into a single API. Here is what it solves, the operational cost it adds, and when a simpler gateway is enough.","category":"code","date":"August 19, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":300},{"slug":"hermetic-builds-explained-2026","title":"Hermetic Builds Explained: Same Inputs, Same Output","excerpt":"A hermetic build depends only on declared inputs. Here is what that property gives you, the common leaks that break it, and how to move toward it incrementally.","category":"code","date":"August 19, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":130},{"slug":"monorepo-tooling-compared-2026","title":"Monorepo Tooling Compared: What You Actually Need","excerpt":"Monorepo tools solve task orchestration and caching, not repository layout. Here is what each tier provides and how to tell when you have outgrown the simple option.","category":"code","date":"August 19, 2026","author":"ByteLedger Team","readTime":"3 min read","hue":150}],"newer":{"slug":"cd-vs-savings-account-2026","title":"CD vs savings account in 2026: which one should you choose?","excerpt":"CDs and high-yield savings accounts both earn real interest in 2026, but they serve different jobs. Here is how to decide which one fits your money.","category":"finance","date":"February 20, 2026","author":"ByteLedger Team","readTime":"5 min read","hue":282},"older":{"slug":"chromebook-vs-laptop-2026","title":"Chromebook vs laptop in 2026: which one should you actually buy?","excerpt":"Chromebooks have closed the gap with Windows laptops on most everyday tasks, but the right choice still depends on what software you need. Here is the honest comparison for 2026.","category":"tech","date":"February 20, 2026","author":"ByteLedger Team","readTime":"4 min read","hue":236}}