Getting Started with AWS CloudFront
Welcome to AWS CloudFront
CloudFront is AWS's Content Delivery Network (CDN). It sits in front of your S3 bucket or EC2 server and caches your content at over 400 edge locations around the world — so a user in Tokyo gets assets served from a Tokyo server, not from your us-east-1 origin.
For a React app served from S3, CloudFront is the difference between a 2-second load time in Asia and a 200ms load time. It's also required to use HTTPS with a custom domain on S3.
What You'll Learn
- Distributions — the CloudFront resource that wraps your origin
- Origins — S3 buckets, EC2/ALB, or any HTTP server as the source
- Edge locations vs. regional caches — how CloudFront's two-tier caching works
- Cache behaviors — different caching rules per URL path (
/api/*vs./*) - TTL and invalidations — controlling how long content is cached and how to clear it
- HTTPS with ACM — using AWS Certificate Manager for a free SSL cert on CloudFront
- Custom domain — pointing
yourapp.comto a CloudFront distribution via Route 53 - S3 + CloudFront pattern — the standard setup for hosting a static frontend
Prerequisites
- An AWS account
- An S3 bucket (for static sites) or a running EC2/load balancer (for dynamic apps)
- Basic understanding of how HTTP caching works