1.CDN caching for static assets and cacheable responses
A CDN (content delivery network) is a globally distributed set of caching servers, positioned close to end users geographically, that cache and serve content on behalf of an origin server. It removes both the network distance and the origin's repeated-serving cost for anything that can be safely cached — classically images, CSS and JS, but also API or page responses that are the same for many users.
Key features
- Origin server: the source of truth the CDN caches from — the CDN is a caching layer in front of it, not a replacement for it
- Edge location (PoP — point of presence): a CDN's server, geographically distributed, that serves cached content to nearby users
- Static assets — images, CSS, JS, video, downloadable files — are the classic, easiest CDN caching target since they rarely change per-request
- Dynamic but cacheable content — an API response or rendered page that is identical for many users for a bounded time — can also be CDN-cached, not just static files
- A CDN reduces both latency (serving from a nearby edge instead of a distant origin) and origin load (the origin is only hit on a cache miss)
What typically is and isn't a good CDN caching candidate
- Client — e.g. Tokyo
- leads to CDN edge (request)
- CDN edge — nearby PoP
- leads to Hit: ~5ms (cached)
- leads to Origin (miss: fetch + cache)
- Hit: ~5ms — served from edge
- Origin — us-east, single region
Command
Client → CDN edge (near client)
├─ cache hit → serve from edge, fast
└─ cache miss → fetch from origin,
cache it, then serveA CDN caches content at edge locations near users, cutting both network latency and origin load — for static assets by default, and for dynamic content when it is explicitly marked cacheable and does not vary per user.