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, cutting latency from 200ms to 20ms. 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.