AWS CloudFront 00:00:01 The release file travels from Dublin to Tokyo A game studio ships an update through Amazon CloudFront. The Dublin edge misses. In this example a regional edge cache and optional Origin Shield sit between the viewer and the S3 origin. A viewer in Ireland asks. The edge has no copy. The European regional cache has none either. Origin Shield fetches the object from S3. Shield, region and edge each keep a copy. Tokyo's edge and region miss, but the shield has it. S3 hears nothing. Shared upstream cache layers can collapse origin demand from many geographically distributed edges. A hit at the shield and a hit at the nearest edge save different amounts of latency. 00:00:46 A path selects a behavior One distribution serves public game assets and an API. The cache behavior determines the origin and the policies that apply. The first matching path pattern in configured order wins. Three patterns and a default. The request is /static/app.3f9a.js. /api/* does not match. The static path matches this asset. Its long freshness lifetime belongs to this example's versioned static files. A path that matches none of the specific patterns falls through to the default behavior. Review broad patterns alongside more specific ones. A private route accidentally captured by a public caching behavior is a correctness issue, even when delivery is very fast. 00:01:37 Fail over an eligible read The primary origin returns an error on a cache miss. With an origin group and the configured failure statuses, CloudFront can try an eligible request against the secondary origin. Misses go to the primary. Objects are copied to the second Region in the background. 503 is one of the chosen failure codes. The same GET goes to the secondary. The viewer gets the object. A customer write using POST is outside this origin-failover read path and needs its own recovery contract. There is no memory of the failure: the primary is tried first again. Origin failover does not make a remote copy instantaneously current or make write retries safe. Check allowed methods, replication lag and the status codes that actually trigger the fallback. 00:02:27 Two ways to release a replacement The game studio changes an asset. An invalidation and a newly versioned filename both affect what viewers receive, but their paths through existing caches differ. Edge, region and shield hold version 1. The request removes the object from edge and regional caches. The next requests fall through and fetch version 2. A new name is a new key, so browsers ask for it too. The old file is still there. Point the HTML at the old name. Keep old versioned assets long enough to roll the page back by changing references. Browser-held copies of an old URL obey their own local caching rules. 00:03:11 Test a personalized page with two shoppers At a separate store, Asha's profile and Lee's profile have the same URL. Whether those objects are safe to cache depends on the configured policy, including the minimum TTL and cache key. In this example a nonzero minimum TTL can make CloudFront cache a response despite the origin marking it private. Same path, same key. Lee gets Asha's page. Use a suitable caching-disabled behavior for the personal page and verify both sessions independently. Run an end-to-end test using two distinct sessions. A shared cache must preserve the identity and privacy semantics of the application, regardless of its hit rate.