Solution Overview
- The viewer requests the website at www.example.com.
- If the requested object is cached, CloudFront returns the object from its cache to the viewer.
- If the object is not in CloudFront’s cache, CloudFront requests the object from the origin (an S3 bucket).
- S3 returns the object to CloudFront, which triggers the Lambda@Edge origin response event.
- The object, including the security headers added by the Lambda@Edge function, is added to CloudFront’s cache.
- (Not shown) The objects is returned to the viewer. Subsequent responses for the object are served from the CloudFront cache.