CDN Caching & Edge Delivery
A CDN (Content Delivery Network) caches content at edge servers distributed globally — Cloudflare, AWS CloudFront, Fastly, Azure CDN. A user in Tokyo gets the response from a Tokyo edge node instead of your server in Virginia, often cutting cross-region latency substantially on cache hits — measure your paths rather than assuming fixed milliseconds.
CDNs excel at static content: images, videos, CSS, JavaScript bundles. Configure cache behaviors by path pattern — /assets/ gets a long TTL, /api/ bypasses the cache. Cache purging invalidates edge copies when you deploy new assets. For dynamic content, CDNs support edge-side includes and stale-while-revalidate at the edge.
The key decision is what to cache at the edge vs what must reach your origin server. User-specific API responses (my profile, my orders) should not be cached at the CDN. Public, identical responses (product catalog, blog posts, static pages) are ideal CDN candidates.
Check your understanding
What content fits CDN caching best?Show answerHide answer
Answer
Public, identical responses — static assets and cacheable pages/APIs that do not vary by user.Why purge/invalidate on deploy?Show answerHide answer
Answer
Edge nodes may keep old assets until TTL or explicit invalidation.Are edge latency numbers universal?Show answerHide answer
Answer
No — they depend on geography, cache hit, TLS, and origin fallback. Measure your paths.