01Chapter 1: How a CDN and edge caching workThis chapter explains what a content delivery network (CDN) does, how Amazon CloudFront handles a request from a viewer to an S3 origin, and why a cache hit or miss changes what the viewer experiences. Later chapters build on this model when they configure distributions, cache policies, and invalida7 min read
02Chapter 2: Using an S3 bucket as an originThis chapter assumes you know basic S3 concepts (buckets, objects, keys), can read HTTP status codes, and can run AWS CLI commands. Earlier chapters covered how a CDN caches content at edge locations. This chapter covers what CloudFront needs from the bucket behind it. Choosing between the two S3 en6 min read
03Chapter 3: Choosing the REST endpoint or the website endpointThis chapter assumes you know what an S3 bucket, object, and key are, and that you can read an HTTP status code and a JSON bucket policy. It also assumes you have seen the previous chapter on using a bucket as a CloudFront origin. By the end you should be able to pick the right S3 endpoint for a dis6 min read
04Chapter 4: Creating a CloudFront distributionA distribution is the top-level CloudFront resource. It ties together the origins CloudFront fetches from, the cache behaviors that decide how each request is handled, and the domain name viewers use. This chapter walks through creating one that fronts an S3 bucket and explains the settings that mat6 min read
05Chapter 5: Keeping the bucket private with Origin Access ControlThis chapter assumes you can read an S3 bucket policy, know that CloudFront serves content from a distribution, and can run AWS CLI commands. It covers how Origin Access Control (OAC) lets CloudFront read a private bucket, how to set it up, and the errors you are most likely to hit. The bucket polic5 min read
06Chapter 6: Writing the bucket policy that trusts your distributionThis chapter covers the bucket policy that lets one CloudFront distribution read from a private S3 bucket. It assumes you know S3 buckets, objects, and keys, can read IAM JSON policies, and have run AWS CLI commands. It also assumes you have created an Origin Access Control (OAC) and attached it to 6 min read
07Chapter 7: Cache behaviors and path patternsThis chapter shows how one CloudFront distribution applies different rules to different URL paths. It assumes you have read the earlier chapters on distributions, Origin Access Control, and the bucket policy. It also assumes you can read a CloudFormation YAML excerpt and use curl to inspect respon5 min read
08Chapter 8: Cache policies and what goes into the cache keyThis chapter assumes you can read a CloudFront distribution definition, you know what an S3 origin is, and you understand HTTP request headers, cookies, and query strings. It covers how CloudFront decides whether two requests are the same request. That decision controls your cache hit ratio.6 min read
09Chapter 9: Controlling freshness with TTLs and Cache-ControlThis chapter assumes you have a working distribution with an S3 origin and a cache behavior (see the earlier chapters), and that you can read HTTP headers and run AWS CLI commands. It covers how long CloudFront and browsers keep a copy of an object, which settings decide that, and which mistakes cau5 min read
10Chapter 10: Default root object and custom error pagesThis chapter covers two settings that decide what a visitor sees when the URL does not name a file, or names a file that does not exist. The first is the default root object. The second is custom error responses. Both belong to the distribution itself, so they apply to every cache behavior.6 min read
11Chapter 11: Publishing updates: invalidations versus versioned file namesWhen you change a file in S3, CloudFront may keep serving the old copy from its edge locations until the cached copy expires. This chapter covers the two ways to get new content to viewers: invalidating cached paths, and giving changed files new names. It also covers how to combine them in a deploy.6 min read
12Chapter 12: Custom domain names and HTTPS with ACMThis chapter assumes you already have a working distribution with a private S3 origin, as built in the earlier chapters. You should also be comfortable with DNS records (A, AAAA, CNAME) and running AWS CLI commands. By the end you will serve the site from your own domain, such as www.example.com, 5 min read
13Chapter 13: Adding security and CORS headers with response headers policiesThis chapter assumes you can read a CloudFormation template and have a working distribution with an S3 origin, as built in the earlier chapters. It also assumes you know what an HTTP response header is and have seen a CORS error in a browser console.5 min read
14Chapter 14: Restricting private content with signed URLs and cookiesThis chapter covers how to make CloudFront serve some objects only to viewers who hold a valid signature. It assumes you can read the distribution and cache behavior setup from earlier chapters. You should also be comfortable with OAC, the HTTP Cookie header, and running the AWS CLI and OpenSSL. P5 min read
15Chapter 15: Monitoring cache performance and understanding costThis chapter assumes you have a working distribution with a private S3 origin (Origin Access Control and a bucket policy), and that you know cache policies, TTLs, and invalidations from earlier chapters. You should be comfortable running AWS CLI commands and reading basic Python.6 min read