CloudFront & Edge

AWS SAA SAA-C03 · Design High-Performing Architectures

By Abu Anns · Last updated 20 November 2026Exam version: SAA-C03 (current)

CloudFront: content delivery at the edge

Amazon CloudFront is a content delivery network (CDN). It caches copies of your content at edge locations — data centers in cities around the world — so users download from a location near them instead of from your origin server. The result is lower latency and less load on the origin. A CloudFront distribution defines how content is served: its origin is where CloudFront fetches content it does not already have cached (an S3 bucket, an ALB, an EC2 instance, or any HTTP server), and its cache behaviors define which requests are cached, for how long, and how they are handled.

When a user requests an object, CloudFront checks the nearest edge location. On a cache hit, it serves the object immediately. On a cache miss, it fetches the object from the origin, serves it, and stores a copy for the next request. The time to live (TTL) controls how long an object stays cached; when content changes, you can invalidate the cached copy to force CloudFront to fetch the new version, although invalidations take minutes and are best used sparingly — versioned filenames are the cleaner way to publish updates. CloudFront serves content over HTTPS, integrates with AWS Certificate Manager for custom domain certificates, and supports HTTP/2 and HTTP/3.

Securing and controlling access to content

CloudFront is also a security layer. When the origin is an S3 bucket, Origin Access Control (OAC) restricts bucket access so that only CloudFront can read the objects — users cannot bypass the CDN and go straight to S3. OAC is the current recommended mechanism (it replaces the older Origin Access Identity, OAI). For content that should only be available to certain users, signed URLs and signed cookies grant time-limited access: a user without a valid signed URL gets an error. Geo restriction (also called geo-blocking) can allow or deny access by country. And AWS WAF integrates with CloudFront to filter malicious requests — SQL injection attempts, cross-site scripting, rate-based rules — before they reach the origin.

Running code at the edge: Lambda@Edge and CloudFront Functions

CloudFront can run code at edge locations, close to users. CloudFront Functions is for lightweight, high-volume tasks that run on every request: URL rewrites, header manipulation, simple redirects, and basic authorization checks. It runs on the viewer-facing triggers only and has tight resource limits. Lambda@Edge is more powerful: it runs full Lambda functions at the edge on both viewer and origin triggers, supporting heavier logic such as dynamic content generation, authentication flows, and A/B testing — at higher cost and latency than CloudFront Functions. The exam's rule: use CloudFront Functions for simple request/response tweaks, Lambda@Edge when you need real compute or access to the network and origin triggers.

Global Accelerator and the edge family

AWS Global Accelerator is often confused with CloudFront, but it solves a different problem. CloudFront caches content at the edge; Global Accelerator improves the network path for traffic that cannot be cached — dynamic API calls, gaming, real-time applications. It gives your application two static anycast IP addresses, and user traffic enters the AWS global network at the nearest edge location, then travels over AWS's private backbone to your application in the closest Region, avoiding the unpredictable public internet. Global Accelerator also provides automatic failover between Regions: if the endpoint in one Region fails health checks, traffic shifts to a healthy endpoint elsewhere. The decision rule: cacheable static content goes through CloudFront; non-cacheable dynamic traffic that needs low latency and global failover goes through Global Accelerator.

Two related services round out the edge picture. Amazon Route 53 (covered in its own guide) provides DNS routing that can direct users to the nearest healthy endpoint. AWS Outposts extends AWS infrastructure into your own data center for workloads that must run on-premises for latency or data-residency reasons — rarely the answer in SAA questions, but worth knowing as the hybrid option.

Caching behavior in depth

CloudFront's performance depends on how it decides what to cache and for how long. Each cache behavior matches a URL path pattern (such as /images/*) to settings: which origin to use, how long to cache, and which request elements form the cache key. By default the cache key is the URL, but you can include headers, cookies, or query strings when the response depends on them — for example, including the Accept-Language header when the origin serves different content per language. Including too much in the cache key fragments the cache and reduces the hit rate, so the exam favors minimal cache keys. Cache policies and origin request policies separate these concerns: the cache policy controls what goes into the cache key and the TTL values, while the origin request policy controls what is forwarded to the origin on a cache miss.

TTL values deserve care. The default TTL applies when the origin does not specify a caching duration; the minimum and maximum TTL bound what the origin can request. Setting TTLs too short sends too much traffic to the origin; setting them too long serves stale content. The cleanest way to publish updates is versioned filenames (app-v2.js instead of app.js), which sidestep caching entirely because the new file has a new URL. Price classes let you limit which edge locations serve your content, trading global reach for lower cost — useful when your users are concentrated in one part of the world. CloudFront also supports real-time log delivery to Kinesis Data Streams for immediate visibility into requests, and standard access logs to S3 for analysis.

Multiple origins and origin failover

A distribution can have more than one origin, and cache behaviors route different paths to different origins — for example, /api/* to an Application Load Balancer and everything else to an S3 bucket. Origin groups add failover: you designate a primary origin and a secondary origin, and CloudFront automatically retries the secondary when the primary returns an error status (such as 500, 502, 503, or 504). This is the standard pattern for serving a static fallback site from S3 when the application origin is unhealthy. CloudFront also supports custom origins — any HTTP server, including one outside AWS — so it can accelerate content that does not live on AWS at all. When the origin is an ALB or EC2 instance, CloudFront can be configured to forward the original viewer information (IP address, protocol) in headers so the application still sees the real client. Combined with OAC for S3 origins, WAF for request filtering, and signed URLs for restricted content, these features make CloudFront the front door for most public-facing AWS architectures.

CloudFront pricing notes

CloudFront charges for data transfer out to viewers and for the number of requests served, with prices varying by edge location region. Data transfer from the origin to CloudFront is free, and the first 1,000 invalidation paths each month are free. Because cached responses are served from the edge rather than the origin, a high cache hit ratio usually lowers the total cost of serving content compared with serving it directly from S3 or EC2.

Advertisement

Exam traps to watch for

Practice questions

Test yourself on this guide. Answers are checked instantly, with a full explanation for each question.

Q1.A company serves product images from an S3 bucket to users worldwide. Users in distant Regions report slow load times, and the S3 request costs are high. Which solution BEST improves performance and reduces origin load?

Report an error

Q2.A company serves private video content through CloudFront from an S3 origin. Users must not be able to access the videos by going directly to the S3 bucket URL. Which solution enforces this?

Report an error

Q3.A company sells premium training videos through CloudFront. Only paying customers should be able to view a video, and each customer's access should expire after 24 hours. Which solution meets these requirements?

Report an error

Q4.A real-time multiplayer game runs in two AWS Regions. Players connect over the public internet and experience high latency and jitter during peak hours. The game traffic cannot be cached. Which AWS service BEST improves latency for the players?

Report an error

Q5.A company uses CloudFront to serve a website and needs to add a security header to every response and redirect all HTTP requests to HTTPS. The logic is simple and must run on every request with minimal added latency. Which solution is MOST appropriate?

Report an error

Q6.A website's images are cached by CloudFront with a TTL of 24 hours. The company publishes updated images with the same filenames and needs users to see the new images immediately. What is the BEST way to achieve this?

Report an error

Q7.A company wants to protect its CloudFront-served application from common web attacks such as SQL injection and cross-site scripting, and to block requests from known malicious IP addresses. Which AWS service should be integrated with the CloudFront distribution?

Report an error

Q8.A company's application is deployed in two Regions behind an Application Load Balancer in each Region. The company wants users to be automatically routed to a healthy Region if one Region fails, using static IP addresses that do not change during failover. Which solution meets these requirements?

Report an error