What should the developer do next to redirect requests on cache misses?
Create a CloudFront function to redirect requests based on the value of the CloudFront-Viewer-Country header. Associate the CloudFront function with the distribution’s origin request event.
Create a Lambda@Edge function to redirect requests based on the value of the CloudFront-Viewer-Country header. Associate the Lambda@Edge function with the distribution’s origin request event.
Create a Lambda@Edge function to redirect requests based on the value of the CloudFront-Viewer-Country header. Associate the Lambda@Edge function with the distribution’s viewer request event.
Create a CloudFront function to redirect requests based on the value of the CloudFront-Viewer-Country header. Associate the CloudFront function with the distribution’s viewer request event.
Explanations:
CloudFront functions cannot be used for origin request events. They are limited to viewer request or response events.
Lambda@Edge functions can be used for origin request events, and they can inspect the CloudFront-Viewer-Country header to redirect requests to the nearest S3 bucket.
Lambda@Edge functions associated with the viewer request event do not have access to the content that is being requested from the origin, so they can’t perform the necessary redirect on cache misses.
CloudFront functions cannot be used for viewer request events in this context because they can’t access the S3 bucket or perform the redirect effectively when content is not cached.