Core idea
A CDN spreads edge nodes worldwide, caching static content near users. The origin serves once; afterwards responses come from nearby, cutting latency and origin load.
How a request reaches the edge
- The user hits
cdn.example.com; DNS returns the nearest edge IP by location; - The edge serves from cache on a hit;
- On a miss it fetches from the origin, caches, then returns.
Two cache actions
| Action | Effect |
|---|---|
| Purge | Drop old cache so the next request re-fetches the new version |
| Prefetch | Push content to edges proactively to avoid a cold first visit |
What belongs on a CDN
- Good: images, scripts, styles, fonts, video -- static assets;
- Bad: dynamic content with private user data (it would leak to others); mark those
Cache-Control: privateor serve from origin.