CDN & edge caching
Serve content from servers near the user to cut latency and offload your origin.
Visual model
Move the answer closer to the user
How a CDN works
A CDN is a global fleet of edge servers. Each user is routed to a nearby edge.
The edge serves a cached copy when available. On a miss, it fetches the asset from your origin and stores it for the next request.
The shorter trip lowers latency and keeps most traffic away from the origin.
CDNs are ideal for static assets and large media, including images, video, scripts and downloads. They can also cache API responses or run dynamic work at the edge.
Getting caching right
Use Cache-Control headers and TTLs to decide what the edge stores and for how long.
Cache too little and every request reaches the origin. Cache too much and one user's private response may reach another user.
- Never cache personalized or authenticated responses at a shared edge. You may leak one user's data to another.
- Bust stale assets after a deploy with versioned/fingerprinted URLs (e.g. app.9f3a.js) or an explicit purge.
- A high edge hit ratio helps you survive viral spikes. The edge takes the load instead of your origin.
See it
Public content can be shared. Private data cannot.
Key takeaways
- A CDN cuts latency by distance and offloads the bulk of read traffic from your origin.
- Version asset URLs so deploys invalidate cleanly. Never share-cache personalized data.
- For static-heavy or global products, the CDN is your first and biggest line of defense against spikes.