Which solution will meet these requirements?
Create an AWS Lambda function that calls the Createlnvalidation API operation when a change in cache time is necessary.
Add a Cache-Control: max-age directive to the object at the origin when content is being returned to CloudFront.
Add a no-cache header through a Lambda@Edge function in response to the Viewer response.
Add.an Expires header through a CloudFront function in response to the Viewer response.
Explanations:
Using an AWS Lambda function to call the CreateInvalidation API would allow the administrator to manually invalidate cached content, but it does not control the TTL behavior directly. This is not a suitable solution for dynamically varying TTL values.
Adding aCache-Control: max-agedirective at the origin allows the administrator to specify a custom TTL for individual pages. This directive overrides the default TTL behavior of CloudFront and enables varying TTL per object, while still respecting the distribution’s max and min TTL limits.
Adding ano-cacheheader through a Lambda@Edge function would prevent caching entirely for the affected responses, which contradicts the requirement of varying TTLs. This is not suitable for controlling TTL variations.
Adding anExpiresheader through a CloudFront function in the Viewer response would not be effective for setting dynamic TTLs for cached content. TheExpiresheader is not the preferred method for controlling cache durations in CloudFront.Cache-Controlis the correct header for this purpose.