0
votes

I read

If you configure CloudFront to forward all headers to your origin for a cache behavior, CloudFront never caches the associated objects. Instead, CloudFront forwards all requests for those objects to the origin. In that configuration, the value of Minimum TTL must be 0.

now I set min TTL on 0 and tried to forward all headers I get an error from CloudFront: You can not choose to forward all headers with an S3 origin.

How can I make every request check the s3 origin (so that new objects in the buckets are updated in the CloudFront immediately)

1

1 Answers

2
votes

You can't forward all headers to S3 unless your bucket name matches the domain name, exactly, and even then it isn't recommended.

Instead, set Minimum TTL, Default TTL, and Maximum TTL all to 0.

Default TTL is used when the object is stored in the bucket without a Cache-Control value defined. Maximum TTL is used when Cache-Control specifies a non-zero TTL (CloudFront will coerce any larger value down to Maximum TTL for its internal purposes). Minimum TTL should always be set to 0 except in very rare cases.

Note that changing these values requires an invalidation, or objects already in the cache may use prior values.


Or, when writing objects to the bucket, add s-maxage=0 to the Cache-Control header value and ensure that Minimum TTL is set to 0.