A company is hosting a high-traffic static website on Amazon S3 with an Amazon CloudFront distribution that has a default TTL of 0 seconds. The company wants to implement caching to improve performance for the website. However, the company also wants to ensure that stale content is not served for more than a few minutes after a deployment. Which combination of caching methods should a solutions architect implement to meet these requirements? (Choose two.)
- ASet the CloudFront default TTL to 2 minutes. (correct answer)
- BSet a default TTL of 2 minutes on the S3 bucket.
- CAdd a Cache-Control private directive to the objects in Amazon S3.
- DCreate an AWS Lambda@Edge function to add an Expires header to HTTP responses. Configure the function to run on viewer response.
- EAdd a Cache-Control max-age directive of 24 hours to the objects in Amazon S3. On deployment, create a CloudFront invalidation to clear any changed files from edge caches. (correct answer)
Reveal answer & explanationHide answer
The correct answer is A, E. Option A: Set the CloudFront default TTL to 2 minutes. Option E: Add a Cache-Control max-age directive of 24 hours to the objects in Amazon S3. On deployment, create a CloudFront invalidation to clear any changed files from edge caches.
Explanation
Amazon S3 provides durable, scalable object storage that is fully managed. Amazon CloudFront caches content at edge locations to reduce latency and offload origins.