Content Delivery Networks (CDN)

A CDN is a global network of "Edge" servers. Its job is to move content as close to the user as possible. Think of it like a local convenience store: instead of driving across the country to a central warehouse for milk, you grab it from the corner store (The Edge). The catch? This works perfectly for non-changing goods (static images, CSS, JavaScript files). If you need something custom-made just for you (like viewing your bank statement), the store still has to call the central warehouse (The Origin) to fetch the real data.

💻
User
(London)
Edge Server
(London)
Cache Hit
🏠
Origin Server
(US-East)
Cache Miss

The blue dot represents your request. It either stops at the Edge (Fast) or travels to the Origin (Slow).

Comparison: Hosting vs. CDN

Feature Standard Web Hosting CDN (Content Delivery Network)
Main Purpose To store your files and database. To distribute files globally.
IP Address The "Real" IP of your server. A "Proxy" IP near the user.
Performance Varies by user location. Consistent, low-latency worldwide.
Traffic Handling Can crash if too many visit at once. Absorbs massive traffic spikes.

The Lifecycle of a Request

  1. User Request: A user in London wants to see viewip.org.
  2. DNS Routing: Through Anycast, the request is sent to the nearest CDN Edge node in London.
  3. Cache Check:
    • HIT: The Edge node already has the image/file. It serves it in 10ms.
    • MISS: The Edge node doesn't have it. It fetches it from the US Origin, serves the user, and saves a copy for the next person.

Behind the Scenes: Most modern websites use a "Hybrid" approach. You host your main site on a provider like AWS or a VPS, then put a CDN like Cloudflare in front of it. This gives you the control of hosting with the speed of a CDN.