SysPadLessons › CDN and edge lessons › CloudFront

How CloudFront works

Global Content Delivery Network with 600+ edge locations. Caches static and dynamic content close to users, reducing origin load and improving latency. Integrates with WAF and Shield.

Physics is the enemy of a fast website: bytes take time to cross the planet. A CDN cheats it by keeping copies of your content in hundreds of locations near users. CloudFront serves each visitor from the closest edge, so a page loads in milliseconds and your origin barely breaks a sweat.

What you will learn

Content near the user

CloudFront runs a global network of edge locations. A request is routed to the nearest edge instead of your single origin (S3, an ALB, or any HTTP server), so the data travels a short distance, not across the world.

Cache miss vs cache hit

On a cache miss (first request, or expired copy), the edge fetches the object from the origin and stores it. On a cache hit, the edge serves its stored copy directly, fast for the user and zero work for the origin.

So a CDN does two things at once: cuts latency for users and slashes load on your origin.

Static sites and assets, images/video, downloads, and cacheable API responses.

Cache keys and TTL

CloudFront identifies a cached object by its cache key (by default the URL, optionally including headers/query strings). The TTL sets how long an edge serves a copy before re-checking the origin. To remove content early, you issue an invalidation.

More than caching

CloudFront also terminates TLS at the edge, integrates with WAF and AWS Shield for security and DDoS protection, and can run code at the edge (CloudFront Functions / Lambda@Edge) to tweak requests and responses close to users.

Flashcards

Why does a CDN like CloudFront make sites faster globally?
It serves content from an edge location near the user, so data travels a short distance instead of from a single distant origin.
Cache miss vs cache hit in CloudFront?
Miss: edge fetches from the origin and stores it. Hit: edge serves the cached copy, fast for users, no origin load.
What controls how long content is cached, and how do you purge early?
The TTL sets cache lifetime; an invalidation removes content before it expires.
Long TTL vs short TTL, the trade?
Long: higher hit rate and origin offload, but risk of stale content. Short: fresher, but more origin traffic.
Name CloudFront features beyond caching.
TLS termination, WAF/Shield security and DDoS protection, and edge compute (CloudFront Functions / Lambda@Edge).

Sources

Open the SysPad canvas · Official CloudFront documentation

Other CDN and edge lessons