Amazon CloudFront is the content delivery network (CDN) operated by Amazon Web Services (AWS) that caches and delivers websites, APIs, video and software downloads from a global network of edge locations instead of from a single origin server. In content delivery on the Internet, CloudFront sits between users and the origin, terminates their connections nearby, answers from cache when it can and fetches from the origin only when it must.
CloudFront is tightly integrated with other AWS services such as Amazon S3, Elastic Load Balancing, AWS WAF, AWS Shield and Lambda, which makes it the default edge layer for workloads hosted on AWS, although it can front any HTTP origin, including servers outside AWS.
How Amazon CloudFront delivers a request
CloudFront delivers a request by routing the user to a nearby edge location, checking the local cache and, on a miss, forwarding the request upstream toward the origin. DNS resolution of the distribution domain (for example a name ending in cloudfront.net) returns addresses of an edge location selected by latency-based and capacity-aware routing, so the TCP, TLS and QUIC handshakes complete over a short network path.
Behind the edge locations sit regional edge caches, a larger mid-tier layer that holds objects evicted from smaller edge caches. An optional Origin Shield adds a single designated caching region in front of the origin, so that all edge traffic for a given object converges on one point. This tiered caching design raises the overall cache hit ratio and reduces the number of requests that ever reach the origin server.
The following table summarizes the layers a request may pass through and the role each layer plays.
| Layer | Role | Typical effect |
|---|---|---|
| Edge location | Terminates connections and serves cached objects | Lowest latency for popular content |
| Regional edge cache | Holds less popular objects for many edges | Fewer origin fetches for long-tail content |
| Origin Shield | Single collapsing point before the origin | Lower origin load and egress |
| Origin | Authoritative source such as S3 or a load balancer | Handles misses and dynamic requests |
Concurrent misses for the same object are combined through request collapsing, so a sudden surge for a new file does not translate into thousands of simultaneous origin requests. Connections from edges to origins are kept alive and reused, which also accelerates uncacheable dynamic requests.
Distributions, behaviors and cache policies
A CloudFront configuration is organized as a distribution, which binds one or more domain names, a TLS certificate, a set of origins and an ordered list of cache behaviors. Each behavior matches a path pattern such as /images/* or /api/* and decides which origin receives the request, which HTTP methods are allowed and how responses are cached.
Caching is controlled by a cache policy, which defines the cache key and the default, minimum and maximum TTL values. A separate origin request policy decides which headers, cookies and query strings are forwarded to the origin without becoming part of the cache key. Separating the two is critical, because adding a header to the cache key fragments the cache, while forwarding it only to the origin does not.
The main configuration objects and their purposes are listed below.
| Object | What it controls | Common mistake |
|---|---|---|
| Cache policy | Cache key components and TTL bounds | Including all cookies in the key |
| Origin request policy | Values forwarded to the origin | Confusing forwarding with keying |
| Response headers policy | Security and CORS headers added at the edge | Duplicating headers set by the origin |
| Origin access control | Signed access from CloudFront to S3 | Leaving the bucket publicly readable |
| Invalidation | Removal of cached paths before expiry | Using it instead of versioned file names |
CloudFront honors Cache-Control and Expires headers from the origin within the bounds set by the policy, and it supports stale-while-revalidate and stale-if-error directives, which let the edge serve slightly outdated content while it refreshes the object or while the origin is failing.
Edge compute, security and protocol features
CloudFront can run code at the edge through two mechanisms with different trade-offs. CloudFront Functions execute lightweight JavaScript in every edge location with sub-millisecond execution limits, which suits header rewriting, redirects and cache key normalization. Lambda@Edge runs Node.js or Python in regional edge caches with longer limits, network access and larger packages, which suits authentication, content generation and calls to other services.
| Property | CloudFront Functions | Lambda@Edge |
|---|---|---|
| Runtime location | All edge locations | Regional edge caches |
| Languages | JavaScript subset | Node.js and Python |
| Network access | Not available | Available |
| Typical tasks | Redirects and header changes | Authentication and origin selection |
| Relative cost | Lower per invocation | Higher per invocation |
Security features operate at the same edge. CloudFront includes AWS Shield Standard against network and transport layer floods, integrates with AWS WAF for application layer rules and rate limiting, supports signed URLs and signed cookies for private content, and offers field-level encryption for sensitive form fields. It supports HTTP/2, HTTP/3 over QUIC, TLS 1.3, WebSocket connections and gRPC, along with Brotli and gzip compression at the edge.
How CloudFront compares with other CDNs
CloudFront competes with Cloudflare, Akamai and Fastly, and the right choice depends mostly on where the origin lives and how much edge programmability the workload needs. All four operate large edge networks with points of presence on every inhabited continent, so raw reach rarely decides the matter on its own.
| CDN | Main strength | Typical fit |
|---|---|---|
| Amazon CloudFront | Native AWS integration and no egress fees from AWS origins | Applications hosted on AWS |
| Cloudflare | Bundled security, DNS and edge platform | Broad sites wanting one integrated edge |
| Akamai | Very large footprint and enterprise media delivery | Large media and regulated enterprises |
| Fastly | Fast purge and programmable caching logic | Publishers needing near-instant invalidation |
A key economic detail is that data transfer from AWS origins to CloudFront is not billed, so serving S3 or EC2 content through CloudFront is often cheaper than serving it directly. Organizations that need resilience or regional price optimization sometimes run CloudFront as one provider in a multi-CDN setup.
Pricing, limitations and common pitfalls
CloudFront is billed mainly by data transfer out to the Internet, by the number of HTTP and HTTPS requests and by optional features such as edge functions, invalidations beyond a free monthly quota and Origin Shield requests. Rates differ by geographic price class, and a distribution can be restricted to cheaper price classes at the cost of higher latency for users in excluded regions. AWS also offers flat-rate plans and committed-use discounts, whose terms change over time.
- Configuration changes propagate in minutes, not seconds, so emergency changes require planning.
- Invalidations are not instantaneous and are billed beyond the free quota; versioned file names are the more reliable strategy.
- An over-broad cache key that includes all headers or cookies collapses the cache hit ratio.
- Leaving an S3 origin public lets users bypass the CDN, its logging and its WAF rules.
- Tight integration with AWS makes migration to another provider more laborious than with a provider-neutral setup.
The idea in brief
Amazon CloudFront is a network of storage points spread around the world that keeps copies of a website’s files close to the people who use them. When someone opens a page, the files come from a nearby point instead of from a distant main server, so the page appears faster.
Think of it as a chain of local warehouses for a single online shop. Popular items are stocked in every warehouse, rarer items in a few regional ones, and only unusual orders go all the way back to the factory. The result is speed for users and less strain on the main server.
A practical scenario
An online learning platform hosts its course videos and web application in a single AWS region in Europe, yet many students connect from South America and Southeast Asia. Page loads from those regions take several seconds, and the origin load balancer struggles every Monday morning when new lessons are released.
The engineering team places CloudFront in front of the platform with three behaviors: long TTLs for versioned static assets, a separate behavior for video segments with Origin Shield enabled in the origin region, and a no-cache behavior for /api/* that still benefits from persistent edge-to-origin connections. The S3 bucket is locked down with origin access control, and a CloudFront Function normalizes query strings before caching.
After rollout, the cache hit ratio for static content exceeds 95 percent, origin requests on release mornings fall sharply, and students in distant regions see pages render in roughly a second. Egress costs also decrease, because traffic from S3 to CloudFront is not billed and the edge absorbs most repeated downloads.