NETWORKING / A CONCEPT NOTE
CDN
serving content from a server near your user
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
A Content Delivery Network (CDN) caches static assets — images, JS, CSS, videos — at edge locations around the world. When a user in Tokyo requests your site, the CDN serves from a Tokyo edge node instead of fetching from your origin server in Virginia. This cuts latency dramatically and offloads traffic from your origin.
02 / FOLLOW THE MECHANISM
How a cdn serves a cached file
User
requests
https://cdn.example.com/logo.webpfrom their browser.DNS
resolves the CDN hostname to the nearest edge server (e.g., Tokyo).
Edge server
checks its local cache. If the file is there and not expired, it serves it immediately (cache hit).
Origin fetch
on a cache miss, the edge fetches from your origin server, caches it, and serves it to the user.
Cache headers
Cache-Control: max-age=31536000tells the edge and browser how long to keep the file.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
check cache headers on a CDN asset
curl -sI https://cdn.example.com/file.jspurge entire CloudFront cache
aws cloudfront create-invalidation --distribution-id DIST_ID --paths "/*"05 / CHECK YOURSELF
Could you explain CDN to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in NetworkingTCP Handshakehow two machines agree to talk