All my assets are stored on S3.
I setup CloudFront on top of it. Therefore I only have one origin on this distribution.
Here is my configuration.

When I get an asset (in this case a css file), here are the headers that are returned.
Content-Type: text/css
Content-Length: 431206
Connection: keep-alive
Date: Tue, 30 Apr 2019 19:58:02 GMT
Last-Modified: Mon, 29 Apr 2019 19:19:06 GMT
ETag: "157d6f76c8edfc3329062f511be86149"
Accept-Ranges: bytes
Server: AmazonS3
Age: 12
Vary: Accept-Encoding
X-Cache: Hit from cloudfront
Via: 1.1 67c0f7cc5ebd46ca00c423ff8dac32d3.cloudfront.net (CloudFront)
X-Amz-Cf-Id: uqlSS3nsE_s2gfeN8XRaLWsrNoLJw7ap7Kuaqv92GbUVcXFKJD4dog==
My expectation is that Cache-Control header would be set, but clearly isn't being returned.
Your expectation is incorrect.
These settings do not set or modify Cache-Control headers -- they only adjust the values CloudFront adopts for its internal TTL for each object.
To set Cache-Control on objects, the header needs to be sent when the object is uploaded to S3, or it can be added in CloudFront using a Lambda@Edge trigger.
See No Cache-Control Header for files from AWS CloudFront with S3 Origin on Server Fault.
See also What is Cloudfront Minimum TTL for? and Confused with minimum, maximum and default TTL in CloudFront here on Stack Overflow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With