Introduction
When a user in Tokyo requests a website hosted in a data center in Virginia, every byte has to travel across the globe, adding noticeable latency. A Content Delivery Network (CDN) solves this by caching copies of content much closer to users, dramatically speeding up delivery for websites, videos, and APIs with a global audience.
Cricket analogy: A fan in Tokyo streaming a match hosted on servers in Virginia experiences buffering lag, just as a CDN like Akamai fixes this by caching the broadcast feed at edge servers close to viewers worldwide.
Explanation
A CDN is a globally distributed network of edge locations (also called points of presence, or PoPs) that cache copies of content close to end users. Instead of every request traveling back to the origin server, nearby edge locations can serve the content directly, reducing round-trip latency and offloading traffic from the origin.
Cricket analogy: A CDN's edge locations are like regional cricket academies scattered across a country -- instead of every young player traveling to the national training center, nearby academies serve most training needs locally, easing pressure on the main facility.
When a request arrives at an edge location, one of two things happens. A cache hit occurs when the requested content is already stored at that edge location and can be served immediately, without contacting the origin server — this is fast and reduces origin load. A cache miss occurs when the content is not present (or has expired) at that edge location; the CDN then fetches it from the origin server, serves it to the user, and typically stores a copy at the edge for subsequent requests, so later requests for the same content become cache hits. Content has a time-to-live (TTL) that determines how long it stays cached before the edge location must re-validate or refetch it from the origin.
Cricket analogy: When a fan requests match highlights, a cache hit is like the regional academy already having the training footage on file to hand over instantly; a cache miss is like the academy having to request it from headquarters first, then keeping a copy on-site (with a TTL) so the next fan's request is instant.
Example
User (Tokyo) --> CDN edge (Tokyo)
1st request: cache MISS -> edge fetches from origin (Virginia) -> caches it -> serves user
2nd request (same object, before TTL expires): cache HIT -> served directly from Tokyo edge, no trip to Virginia# Set a Cache-Control header so a CDN caches a static asset for 1 day
curl -I https://example.com/logo.png
# Response includes: Cache-Control: public, max-age=86400Analysis
CDNs are most effective for content that doesn't change per user and can be safely cached, such as images, videos, CSS/JS files, and static pages. Highly dynamic, personalized content (like a user's private account balance) generally bypasses the CDN cache or uses very short TTLs, since caching it incorrectly could serve one user's data to another. A high cache-hit ratio is the key performance indicator for a CDN — it means most requests are served from the edge, minimizing both latency for users and load on the origin server. Poorly chosen TTLs create a tradeoff: too long, and users see stale content after updates; too short, and the cache-hit ratio drops, increasing origin load and latency.
Cricket analogy: Highlight reels and scorecards cache well because they don't change per fan, but a fan's personal fantasy-league score is private and must be fetched fresh each time -- a high cache-hit ratio means most fans get instant replays, while a TTL set too long shows stale scores after a boundary is hit.
Key Takeaways
- A CDN caches content at geographically distributed edge locations closer to end users to reduce latency.
- A cache hit serves content directly from the edge; a cache miss requires fetching from the origin server first.
- TTL (time-to-live) controls how long cached content remains valid at the edge before revalidation.
- CDNs work best for static, cacheable content; highly dynamic or personalized content needs careful cache configuration.
Practice what you learned
1. What is the primary purpose of a CDN?
2. What happens during a cache hit at a CDN edge location?
3. What occurs on a cache miss?
4. Why is highly personalized, per-user content generally a poor fit for aggressive CDN caching?
Was this page helpful?
You May Also Like
Load Balancing in the Cloud
Learn how cloud load balancers distribute traffic across instances using Layer 4 and Layer 7 techniques and health checks.
Caching Strategies
Compare cache-aside, write-through, and write-behind caching patterns and their consistency and latency tradeoffs.
DNS and Cloud Networking
Understand how cloud DNS services resolve domain names and support advanced routing policies like latency-based and geolocation routing.