Reputation: 5474
I have a file, stored on S3, let's say index.html which is changing once in a while.
I don't want end customer to cache it, so I want to send a http header max-age=0, no-store, no-cache, must-revalidate
.
From what I understand from the doc, if I set this header in S3 metadata, Cloudfront will respect this header, which means Cloudfront will always reread the file for each request.
I don't want Cloudfront to do that, I am happy to invalidate Cloudfront whenever the file has changed.
Is that possible?
Upvotes: 3
Views: 3442
Reputation: 179094
if I set this header in S3 metadata, Cloudfront will respect this header, which means Cloudfront will always reread the file for each request.
That isn't correct.
When Minimum TTL
in CloudFront is set larger than max-age
or s-maxage
, or when the origin response includes any of the no-cache
, no-store
, and/or private
directives, CloudFront still stores the objects for up to the Minimum TTL.
This is why it is called the "minimum" TTL. CloudFront assumes objects with a TTL shorter than this (as indicated by those directives) should still be cached -- just not longer than Minimum TTL. So if this is a large value, the number of requests to S3 will be minimal.
See Specifying How Long Objects Stay in a CloudFront Edge Cache (Expiration).
Upvotes: 3