Course contentsShow
← Software Engineering
Lesson 985 of 1,93330. Caching StrategiesFree lesson

CDN and Edge Caching

Understand content delivery networks, edge locations, and geographic distribution for static and dynamic content.

CDN and Edge Caching

You'll learn how content delivery networks distribute cached content geographically to serve users faster from nearby locations.


What Is a CDN?

A Content Delivery Network (CDN) is a geographically distributed network of servers that cache and deliver your content from locations closer to your users. Instead of every request traveling to your origin server (perhaps on the other coast or another continent), the CDN serves cached content from an edge location—a server physically near the user.

Think of it like having bookstores in every major city instead of one massive warehouse. Customers get their books faster because they're shopping locally, and your central warehouse isn't overwhelmed.

Edge Locations and Geographic Distribution

Edge locations are data centers positioned strategically around the world. When a user in Tokyo requests your website, the CDN routes that request to the nearest edge location in Asia. If the content is cached there (a cache hit), it's served instantly. If not (a cache miss), the edge fetches it from your origin server, caches it locally, and serves future requests from that edge.

This pattern dramatically reduces latency and offloads traffic from your origin servers.

Static vs. Dynamic Content

CDNs excel at caching static content: images, CSS, JavaScript, videos—anything that doesn't change per user. These assets get long TTLs and are served directly from edge caches.

Dynamic content (personalized pages, API responses) is trickier but still benefits. Modern CDNs can cache dynamic content with short TTLs, use edge compute to generate responses, or employ intelligent routing to minimize round-trip time to the origin.

When to Use CDNs

Use CDNs when you need global reach, high traffic volumes, or want to reduce origin server load. They're essential for media-heavy sites, global applications, and anywhere user experience depends on low latency.

Key Takeaway: CDNs cache content at geographically distributed edge locations, serving users from nearby servers to reduce latency, improve performance, and offload your origin infrastructure.