Amazon CloudFront is AWS’s content delivery network (CDN). It terminates viewer requests at edge locations worldwide, can cache responses, and fetches misses from an origin—in this guide, an Application Load Balancer.
What problem does CloudFront solve?
Users far from your ALB Region see higher latency if every request hits the origin. CloudFront shortens that path for cacheable content, absorbs spikes at the edge, and can enforce HTTPS closer to viewers.
When should you use CloudFront?
Put CloudFront in front of an ALB when you want global performance, edge TLS, optional AWS WAF, and a single public hostname. For static files alone, many teams use S3 (or S3 + CloudFront) instead of an ALB origin.
How traffic flows
Viewer → CloudFront edge → (cache hit) response, or (cache miss) origin protocol to your ALB → target group → healthy instances. DNS usually points at CloudFront via Route 53, not directly at the ALB.
Custom domains and ACM
Alternate domain names (CNAMEs) need a certificate from ACM in us-east-1, even if the ALB certificate lives in another Region. Then alias your domain to the distribution in Route 53.
Edge cache + origin.
Static and cacheable responses stay near viewers. Dynamic or uncacheable requests still reach the ALB with policies you control.
ACM for CloudFront is us-east-1 only.
Viewer certificates on the distribution must be requested or imported in N. Virginia. ALB HTTPS certs stay in the ALB Region.
Prefer HTTPS to the origin.
Use an origin protocol policy of HTTPS only (or Match viewer with care) and TLS 1.2+ so traffic is encrypted CloudFront→ALB as well as viewer→CloudFront.
Reference
Core Concepts
Terms you will see while creating a distribution:
Concept
Meaning
Distribution
The CloudFront config that serves your site or API at the edge
Origin
Where CloudFront fetches content (here: ALB DNS name)
Edge location
PoP that answers viewers; may cache responses
Cache behavior
Path pattern rules for protocol, methods, and caching
Cache policy
What makes the cache key (TTL, query strings, headers, cookies)
Origin request policy
What CloudFront forwards to the origin on a miss
Alternate domain (CNAME)
Your hostname (e.g. www.example.com) instead of *.cloudfront.net
Invalidation
Purge cached paths so the next hit refetches from the origin
Before you start
Prerequisites
Have these ready before you create the distribution:
An AWS account with access to CloudFront, Route 53, and your ALB.
A Route 53 hosted zone (or other DNS) you can point at CloudFront. For a custom domain on the distribution, an ACM cert in us-east-1.
Walkthrough
Examples
Create a distribution with an ALB origin, tune caching, point DNS at the edge, then invalidate when needed.
Example 1 — Set the ALB as Origin
Start a distribution and point CloudFront at your load balancer.
Open CloudFront in the AWS console and choose Create distribution.
Under Origin, set Origin domain to your Application Load Balancer.
Set Origin protocol policy (prefer HTTPS only) and Minimum origin SSL protocol to at least TLS 1.2.
AWS Management ConsoleCloudFrontCloudFront
How It Works
The origin is where misses go—here the public ALB DNS name.
Origin protocol policy chooses HTTP or HTTPS for CloudFront→ALB.
TLS 1.2+ avoids weak protocols between the edge and your origin.
ALB security groups must still allow the traffic CloudFront sends to the listener ports.
Example 2 — Default Cache Behavior and Policies
Control how viewers connect and what becomes part of the cache key.
Under Default cache behavior, set Viewer protocol policy (often redirect HTTP to HTTPS) and Allowed HTTP methods for your app.
Under Cache key and origin requests, use recommended settings or pick a cache policy and origin request policy.
Optional: enable AWS WAF if you want a web ACL at the edge.
CloudFrontCloudFrontCloudFront
How It Works
Viewer protocol policy forces or allows HTTPS at the edge (pair with HTTP→HTTPS habits).
Allowed methods must include POST/PUT if your API needs them; GET/HEAD alone is fine for static sites.
Cache policy decides what makes two requests share a cached object.
Origin request policy decides which headers, cookies, and query strings reach the ALB on a miss.
Example 3 — Settings, Certificate, and Create
Add your domain, attach a us-east-1 certificate, then deploy the distribution.
Under Settings, choose a Price class and add an Alternate domain name (CNAME) if you use a custom hostname.
Attach a custom SSL certificate from ACM in us-east-1 when using that custom domain.
Review HTTP versions and defaults, then choose Create distribution and wait until status is Deployed.
CloudFrontCloudFrontCloudFront
How It Works
Price class trades cost vs how many edge locations you use.
Alternate domain names let viewers use www.example.com instead of d123.cloudfront.net.
ACM in us-east-1 proves you own those names for CloudFront TLS.
Deployed means edges have the config; DNS may still point at the ALB until you update it.
Example 4 — Point Route 53 at CloudFront
Send public traffic to the distribution instead of the ALB DNS name.
Open Route 53 and select your hosted zone.
Edit the record for your site: alias A (and AAAA if needed) to the CloudFront distribution.
Save and wait for DNS TTL to expire for clients.
Route 53
How It Works
Viewers resolve your domain to CloudFront, not the raw ALB hostname.
Alias records in Route 53 target the distribution without hard-coding IPs.
The ALB stays the origin—CloudFront still fetches from it on cache misses.
Optional hardening: restrict direct ALB access so only CloudFront can reach it (security groups / managed prefixes).
Example 5 — Invalidate Cached Paths
Force edges to drop stale objects after a deploy.
Open your distribution → Invalidations → Create invalidation.
Enter paths such as /index.html or /* (use broad paths sparingly).
Submit and wait until the invalidation completes.
CloudFront
How It Works
Edges keep objects until TTL expires or you invalidate.
A path invalidation removes matching cached entries so the next request refetches the origin.
/* clears everything for that distribution—handy, but watch quotas and cost.
Better habit: version static filenames (app.abc123.js) so you rarely need invalidations.
Edge Cases & Pitfalls
Most CloudFront surprises come from the wrong ACM Region, over-caching, or DNS still aimed at the ALB.
acm
Certificate not in us-east-1
CloudFront will not list ALB-Region certificates for viewer HTTPS. Request a separate ACM cert in N. Virginia for alternate domain names.
dns
DNS still points at the ALB
Creating a distribution does not move traffic. Update Route 53 (or your DNS) to alias the hostname to CloudFront.
cache
Caching personalized or API responses
If cookies or auth headers matter, use policies that exclude them from the cache key—or disable caching for those paths.
host
Host-header rules on the ALB
If the ALB routes on Host, forward the right Host header via the origin request policy, or add rules for both your domain and the CloudFront domain.
tls
Origin certificate name mismatch
HTTPS to the ALB needs a cert that matches the origin domain / Host you send. Prefer a custom domain on the ALB over relying on the default *.amazonaws.com name.
cost
Broad invalidations and WAF costs
/* invalidations and always-on WAF add spend. Use versioned assets and attach WAF only when you need the rules.
Remember
Key Takeaways
Role: CloudFront is the global edge in front of your origin (here, an ALB).
TLS: viewer certs for custom domains come from ACM in us-east-1; prefer HTTPS to the origin.
Policies: cache and origin request policies control hit ratio and what the ALB sees.
Cutover: alias DNS to CloudFront; invalidate or version assets after deploys.
One line: CloudFront at the edge, ALB as origin, DNS alias to the distribution, ACM in us-east-1 for custom domains.
Frequently Asked Questions
AWS CloudFront is a content delivery network (CDN) that caches and delivers web content, APIs, and media through a global network of edge locations for lower latency and higher transfer speeds.
Yes. Use the ALB DNS name as a custom origin, set an origin protocol policy (HTTPS only is recommended), and ensure security groups and health checks allow CloudFront to reach your targets.
Custom SSL certificates for CloudFront alternate domain names must come from ACM in us-east-1 (N. Virginia), even when your ALB or other origins live in another Region.
An invalidation tells CloudFront to drop cached objects matching specified paths so the next requests fetch fresh content from the origin. Prefer versioned asset filenames when you can to reduce invalidations.
After CloudFront is deployed, point viewer DNS (usually a Route 53 alias A/AAAA) at the CloudFront distribution. Keep the ALB as the origin only—not the public entry point—if you want traffic to use the edge.
No. WAF is optional. Enabling it can block common web exploits at the edge but adds configuration and cost. You can attach a web ACL later.