Skip to content

Instantly share code, notes, and snippets.

@jatin-lab49
Last active May 6, 2020 22:13
Show Gist options
  • Save jatin-lab49/c01c134d23943a32f7e9d091865604a9 to your computer and use it in GitHub Desktop.
Save jatin-lab49/c01c134d23943a32f7e9d091865604a9 to your computer and use it in GitHub Desktop.
TIL-Lab49/cloudfront-caching

Managing S3 cache-control for AWS Cloudfront

Turns out you need can set the Cache-Control value for your S3 objects to be used with AWS Cloudfront in two ways!
The documentation at https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html says it has to be in the MetaData property.
But, you can also have it defined as a CacheControl value on the object. This can be done by passing it as the argument --cache-control max-age=0 to the aws s3 sync command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment