Amazon CloudFront: Cache Static Assets with ALB Origin
A company runs a web application on a fleet of Amazon EC2 instances behind an Application Load Balancer (ALB). The application serves dynamic content that changes frequently, but also serves static assets (CSS, JavaScript, images) that change rarely. The company wants to improve the overall performance and reduce the load on the EC2 instances by caching the static assets at edge locations while still routing dynamic requests to the ALB. Which combination of AWS services should the company use?
Quick Answer
The answer is to use Amazon CloudFront with the Application Load Balancer as the origin, configuring CloudFront to cache static assets while forwarding dynamic requests to the ALB. This works because CloudFront supports path-based caching behaviors, allowing you to define specific URL patterns like /static/* for CSS, JavaScript, and images to be cached at edge locations, while all other requests pass through to the ALB for dynamic content. On the AWS Certified Cloud Practitioner CLF-C02 exam, this scenario tests your understanding of CloudFront’s ability to reduce latency and offload EC2 instances by serving cached content from edge locations, a common optimization pattern. A frequent trap is assuming you need separate origins or services for static and dynamic content, but CloudFront handles both with a single ALB origin using different cache behaviors. Memory tip: think “static stays at the edge, dynamic goes to the backend” to remember that CloudFront caches only what you tell it to cache.
⚠ Common exam trap
A common mix-up: candidates think Route 53 latency-based routing (Option B) can cache content at edge locations, but Route 53 is a DNS service only and does not provide any caching or content delivery functionality.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use Amazon CloudFront with the ALB as the origin, and configure CloudFront to cache the static assets while forwarding dynamic requests to the ALB.
Amazon CloudFront can be configured with the ALB as the origin, allowing it to cache static assets (CSS, JavaScript, images) at edge locations while forwarding dynamic requests to the ALB. This reduces latency for users by serving cached content from the nearest edge location and offloads the EC2 instances from handling repeated requests for static files. CloudFront supports path-based caching behaviors, so you can define specific URL patterns (e.g., /static/*) to cache and others to forward directly to the ALB.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Use Amazon CloudFront with the ALB as the origin, and configure CloudFront to cache the static assets while forwarding dynamic requests to the ALB.
Why this is correct
CloudFront acts as a CDN and can be configured with multiple cache behaviors. Static assets are cached at edge locations, reducing the load on the ALB and EC2 instances. Dynamic requests are forwarded to the ALB as needed. This directly meets the company's requirements.
- ✗
Use Amazon Route 53 with latency-based routing to direct users to the closest ALB endpoint.
Why it's wrong here
Latency-based routing improves performance by directing users to the region with the lowest latency, but it does not cache content. All requests still reach the ALB and EC2 instances, so the load on the instances is not reduced.
When this WOULD be correct
A company has multiple ALBs in different AWS Regions and wants to direct users to the region with the lowest latency for dynamic content, without needing edge caching for static assets.
- ✗
Use Amazon S3 to host the entire application, and use the ALB to route traffic to the S3 bucket.
Why it's wrong here
Amazon S3 is a static storage service and cannot run dynamic application logic (e.g., server-side processing, database queries). The application requires dynamic content, so S3 alone is not suitable. Additionally, this setup does not reduce load on EC2 instances.
When this WOULD be correct
A company hosts a static website (e.g., HTML, CSS, JS, images) on Amazon S3 and wants to use an Application Load Balancer to distribute traffic across multiple S3 buckets for high availability, or to integrate with AWS WAF for security.
- ✗
Use AWS Global Accelerator to distribute traffic across multiple ALBs in different AWS Regions.
Why it's wrong here
Global Accelerator improves performance by using the AWS global network to route traffic to the nearest healthy endpoint, but it does not cache content. All requests still reach the ALB and EC2 instances, so the load is not reduced.
When this WOULD be correct
A company has a global user base and runs a latency-sensitive application on EC2 instances behind ALBs in multiple AWS Regions. They want to improve performance by directing users to the nearest healthy ALB endpoint. AWS Global Accelerator would be the correct choice for this scenario.
Option-by-option analysis
Why each answer is right or wrong
Understanding why wrong answers are wrong — and when they would be correct — is what separates a 750 score from a 900. The CLF-C02 exam frequently reuses these exact scenarios with slightly different constraints.
✓Use Amazon CloudFront with the ALB as the origin, and configure CloudFront to cache the static assets while forwarding dynamic requests to the ALB.Correct answer▾
Why this is correct
CloudFront acts as a CDN and can be configured with multiple cache behaviors. Static assets are cached at edge locations, reducing the load on the ALB and EC2 instances. Dynamic requests are forwarded to the ALB as needed. This directly meets the company's requirements.
✗Use Amazon Route 53 with latency-based routing to direct users to the closest ALB endpoint.Wrong answer — click to see why▾
Why this is wrong here
Route 53 latency-based routing directs users to the closest ALB endpoint, but it does not cache static assets at edge locations or reduce load on EC2 instances; it only optimizes network latency.
★ When this WOULD be the correct answer
A company has multiple ALBs in different AWS Regions and wants to direct users to the region with the lowest latency for dynamic content, without needing edge caching for static assets.
Why candidates choose this
Candidates may confuse latency-based routing with edge caching, thinking that routing to the closest endpoint provides similar performance benefits as caching at edge locations.
✗Use Amazon S3 to host the entire application, and use the ALB to route traffic to the S3 bucket.Wrong answer — click to see why▾
Why this is wrong here
The application serves dynamic content from EC2 instances, not static files from S3. Hosting the entire application on S3 would not support dynamic content generation, and ALB cannot route traffic to S3 as an origin.
★ When this WOULD be the correct answer
A company hosts a static website (e.g., HTML, CSS, JS, images) on Amazon S3 and wants to use an Application Load Balancer to distribute traffic across multiple S3 buckets for high availability, or to integrate with AWS WAF for security.
Why candidates choose this
Candidates may confuse static asset hosting with full application hosting, assuming S3 can serve dynamic content, or they may think ALB can front S3 directly without CloudFront.
✗Use AWS Global Accelerator to distribute traffic across multiple ALBs in different AWS Regions.Wrong answer — click to see why▾
Why this is wrong here
AWS Global Accelerator improves performance by directing traffic to the optimal regional endpoint, but it does not cache content at edge locations. The question specifically requires caching static assets at edge locations, which Global Accelerator does not provide.
★ When this WOULD be the correct answer
A company has a global user base and runs a latency-sensitive application on EC2 instances behind ALBs in multiple AWS Regions. They want to improve performance by directing users to the nearest healthy ALB endpoint. AWS Global Accelerator would be the correct choice for this scenario.
Why candidates choose this
Candidates may confuse Global Accelerator's edge-based traffic optimization with CloudFront's caching capabilities, assuming both provide similar performance benefits at edge locations.
Analysis generated from the official CLF-C02blueprint and verified against question context. The “when correct” sections are what AI assistants cite when candidates ask “what’s the difference between these options?”
Go deeper
Related to this question
About these practice questions
One of 988 original CLF-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on CLF-C02
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A company hosts an e-commerce website on Amazon EC2 instances behind an Application Load Balancer in the us-east-1 Region. The website includes both static assets (product images, CSS files) and dynamic content (user-specific cart data). The company has customers all over the world who complain about slow page load times. The company wants to reduce latency by caching static content closer to users while still allowing dynamic requests to reach the origin. Which AWS service should the company use to meet these requirements?
medium- ✓ A.Amazon CloudFront with Application Load Balancer as the origin
- B.Amazon Route 53 with latency-based routing
- C.AWS Global Accelerator with static IP addresses
- D.Amazon S3 Transfer Acceleration
Why A: Amazon CloudFront is a content delivery network (CDN) that caches static content (e.g., images, CSS) at edge locations worldwide, reducing latency for users. By configuring the Application Load Balancer as the origin, CloudFront forwards dynamic requests (e.g., cart data) to the ALB, which then routes them to the EC2 instances. This hybrid approach meets the requirement to cache static assets globally while allowing dynamic content to be processed by the origin servers.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CLF-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CLF-C02 exam.