7 questionsAmazon CloudFront is a global content delivery network service that caches copies of your website content, such as images, videos, and web pages, at edge locations physically closer to your users around the world, so requests are served from a nearby location instead of traveling all the way back to your origin server, reducing latency significantly.
Example
aws cloudfront create-distribution --origin-domain-name mybucket.s3.amazonaws.com
Real-world example
A global news website uses CloudFront so that a reader in Tokyo loads images and articles from a nearby edge location instead of waiting for content to travel from a server located in the United States.
Likely follow-ups
- What is an edge location and how many does AWS operate?
- How does CloudFront decide which edge location serves a specific user?
S3 & Storage VPC & Networking
CloudFront can pull content from many types of origins including Amazon S3 buckets for static files, Elastic Load Balancers or EC2 instances for dynamic web applications, and even servers outside of AWS entirely, meaning you are not limited to only distributing content that already lives inside AWS.
Example
aws cloudfront create-distribution --origin-domain-name myapp.example.com
Real-world example
An online store uses CloudFront with two different origins, an S3 bucket for its product images and an Application Load Balancer for its dynamic checkout pages, all delivered through a single CloudFront distribution.
Likely follow-ups
- Can a single CloudFront distribution have multiple origins?
- How do you configure CloudFront to route different paths to different origins?
Elastic Load Balancing (ALB NLB & CLB) EC2 & Compute
CloudFront caches content at edge locations based on cache behaviors you configure, including a time to live value that controls how long an object is kept before CloudFront checks the origin again for a fresh copy, and you can also control caching using HTTP headers like Cache Control sent directly from your origin server.
Example
aws cloudfront create-invalidation --distribution-id ABC123 --paths '/images/*'
Real-world example
An e commerce site sets a long cache duration for rarely changing product images but a very short cache duration for its frequently updated pricing page, balancing performance with data freshness.
Likely follow-ups
- What is a cache invalidation and when should you use one?
- How do query strings affect CloudFront caching behavior?
Amazon API Gateway S3 & Storage
CloudFront supports signed URLs and signed cookies that let you generate time limited, cryptographically signed links to private content, as well as Origin Access Control which ensures that an S3 origin can only be accessed through CloudFront and never directly, preventing users from bypassing your distribution entirely.
Example
aws cloudfront sign --url https://example.com/video.mp4 --key-pair-id ABC123 --private-key file://private_key.pem --date-less-than 2026-12-31
Real-world example
A video streaming platform generates signed URLs that expire after a few hours for each customer's video, ensuring that a shared link cannot be used indefinitely by unauthorized viewers.
Likely follow-ups
- What is the difference between signed URLs and signed cookies?
- How does Origin Access Control differ from the older Origin Access Identity?
IAM S3 & Storage
CloudFront integrates directly with AWS WAF, letting you attach web application firewall rules that block common attacks such as SQL injection and cross site scripting before they ever reach your origin server, and it also supports HTTPS enforcement with free SSL certificates through AWS Certificate Manager, keeping data encrypted in transit.
Example
aws cloudfront update-distribution --id ABC123 --distribution-config file://config-with-waf.json
Real-world example
A financial services company attaches AWS WAF rules to its CloudFront distribution to automatically block malicious traffic patterns before they reach its backend servers, reducing the load and risk on its origin infrastructure.
Likely follow-ups
- How do you attach a WAF web ACL to a CloudFront distribution?
- What is the difference between CloudFront's built in DDoS protection and AWS Shield?
AWS WAF & Shield AWS Certificate Manager (ACM)
Lambda at Edge lets you run more complex custom code, written in Node.js or Python, at CloudFront edge locations to modify requests and responses, such as personalizing content or performing authentication checks, while CloudFront Functions offer a lighter weight, faster, and cheaper option written in JavaScript for simpler tasks like URL rewrites or header manipulation, both running much closer to the user than your origin server.
function handler(event) {
var request = event.request;
request.uri = request.uri.replace('/old-path/', '/new-path/');
return request;
}
Real-world example
A media company uses a CloudFront Function to automatically redirect users requesting an outdated URL structure to the correct new page, without ever needing to involve the origin server in that decision.
Likely follow-ups
- When should you use Lambda at Edge instead of CloudFront Functions?
- What are the execution time limits for each option?
Lambda & Serverless Amazon API Gateway
CloudFront can be configured with origin failover, where you designate a primary and a secondary origin, so if the primary origin becomes unavailable or returns errors, CloudFront automatically routes requests to the secondary origin instead, providing seamless failover without requiring any changes on the client side.
Example
aws cloudfront create-distribution --distribution-config file://config-with-origin-group.json
Real-world example
A global SaaS company configures CloudFront origin failover between its primary region's load balancer and a secondary region's load balancer, ensuring customers experience no downtime even if an entire AWS region has issues.
Likely follow-ups
- What criteria trigger a CloudFront failover to the secondary origin?
- How does this compare to using Route 53 health checks for failover?
Amazon Route 53 & DNS Management AWS Backup & Disaster Recovery