Q3 — AWS SAA-C03 Ch.13

Question 3 of 100 | ← Chapter 13

Q903. 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.)

Correct Answer: A. Set the CloudFront default TTL to 2 minutes., C. Add a Cache-Control private directive to the objects in Amazon S3.

Explanation

To meet the requirements of improving website performance through caching and ensuring that stale content is not served for more than a few minutes after deployment, the following two caching methods can be implemented:A. Set the CloudFront default TTL to 2 minutes.By setting the CloudFront default TTL (Time-to-Live) to 2 minutes, CloudFront will cache the content for up to 2 minutes. This means that subsequent requests for the same content within the 2-minute window will be served from the CloudFront cache, improving performance. However, after 2 minutes, CloudFront will check the origin (in this case, the S3 bucket) for any changes to the content.C. Add a Cache-Control private directive to the objects in Amazon S3.By adding a Cache-Control private directive to the objects in Amazon S3, you can control the caching behavior for individual objects. The private directive indicates that the content should be cached by the browser but not by intermediate caches, such as CloudFront edge locations. This allows the browser to cache the content and improve performance for subsequent requests, while ensuring that CloudFront always checks the origin for any changes.Option B suggests setting a default TTL of 2 minutes on the S3 bucket. However, setting the TTL on the S3 bucket directly does not control the caching behavior of CloudFront. CloudFront has its own caching behavior that needs to be configured separately. Therefore, Option B is not the correct choice.Option D suggests creating an AWS Lambda@Edge function to add an Expires header to HTTP responses. While this can be done, it is not the most suitable solution for the given requirements. The Expires header is an older mechanism for controlling caching behavior, and it is recommended to use the Cache-Control header instead. Additionally, using Lambda@Edge for this purpose may introduce additional complexity and overhead. Therefore, Option D is not the most appropriate choice.Option E suggests adding a Cache-Control max-age directive of 24 hours to the objects in Amazon S3 and creating a CloudFront invalidation on deployment to clear any changed files from edge caches. While this approach allows for longer caching of content, it does not ensure that stale content is not served for more than a few minutes after deployment. Additionally, using CloudFront invalidations can be costly and may not be the most efficient way to handle frequent deployments. Therefore, Option E is not the correct choice.In summary, to meet the requirements of improving website performance through caching and ensuring that stale content is not served for more than a few minutes after deployment, setting the CloudFront default TTL to 2 minutes (Option A) and adding a Cache-Control private directive to the objects in Amazon S3 (Option C) are the recommended caching methods to implement.