Customize Cache Time in CloudFront for Better Content Delivery

Fulfilling the Requirement for Custom CloudFront Cache Storage Time

Prev Question Next Question

Question

Your team plans to deliver content to users by using the CloudFront service and an S3 bucket as the source.

You need to ensure that a custom value is placed for the amount of time the object is stored in the CloudFront cache.

Which 2 of the following options can be used to fulfill this requirement?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer - A and C.

This is also mentioned in the AWS Documentation.

For web distributions, to control how long your objects stay in a CloudFront cache before CloudFront forwards another request to your origin, you can:

Configure your origin to add a Cache-Control or an Expires header field to each object.

Specify a value for Minimum TTL in CloudFront cache behaviors.

Use the default value of 24 hours.

Since this is clearly mentioned in the AWS Documentation, the other options are invalid.

For more information on request and response behavior for Cloudfront with S3, please refer to the below URL-

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorS3Origin.html

To ensure that a custom value is placed for the amount of time an object is stored in the CloudFront cache when using an S3 bucket as the source, the following options can be used:

Option B: Configure the CloudFront distribution to add an Expires header field to the object.

By configuring the CloudFront distribution, you can specify the amount of time that an object remains in the cache. This can be achieved by adding an Expires header field to the object. The Expires header field specifies the time after which the object is considered stale and should no longer be served from the cache.

Option C: Specify a value for Minimum TTL in CloudFront cache behaviors.

Another option to set the custom value for the amount of time an object is stored in the CloudFront cache is by setting the Minimum Time To Live (TTL) in the CloudFront cache behaviors. The Minimum TTL specifies the minimum amount of time that an object remains in the cache before CloudFront forwards another request to the origin to determine if the object has been updated.

Therefore, options B and C can be used to fulfill the requirement of placing a custom value for the amount of time an object is stored in the CloudFront cache when using an S3 bucket as the source.

Option A: Configuring the origin to add an Expires header field to the object is not the correct option as the origin server is not used in this case. The content is served from the S3 bucket, which is the source for CloudFront.

Option D: Specifying a value for Minimum TTL in the origin object is also not correct as the origin server is not used in this case. The content is served from the S3 bucket, which is the source for CloudFront.