← Back to Guide
Chapter 02

2. Content Delivery Network (CDN)

Speeding up delivery by bringing content closer to the user.

CDN: Speed at the Edge

Once the browser has the IP address, it sends a request. In a high-availability setup, this request often hits a Content Delivery Network (CDN) first, rather than your main server.

CDN Diagram

Why Use a CDN?

A CDN is a network of servers distributed globally. Its primary roles are:

  1. Latency Reduction: By serving content from a server physically closer to the user (an "Edge Server"), we drastically reduce load times.
  2. Load Offloading: Static assets (images, CSS, JS) are cached at the edge, meaning your main servers don't have to work as hard.
  3. DDoS Protection: CDNs can absorb massive amounts of traffic, protecting your origin infrastructure from attacks.

The Flow

  1. User Request: The user requests image.jpg.
  2. Edge Check: The nearest CDN server checks if it has a cached copy.
  3. Cache Hit: If yes, it returns the file immediately.
  4. Cache Miss: If no, it fetches it from your Origin Server, caches it for next time, and then returns it.