Cache-control can be set on S3 bucket objects.
Setting cache control using aws s3 cp
An object’s metadata may only be changed by overwriting it using the metadata-directive
flag.
Single file:
|
|
All files:
|
|
All image files / specific file extensions
|
|
Setting cache control for websites served by AWS CloudFront
CloudFront is a CDN service provided by AWS. The max-age
directive sets the browser caching age in seconds while another directive named s-maxage
sets the CloudFront caching in seconds.
Choosing from the examples above, add s-maxage=86400
to the --cache-control
flag for all objects in a bucket.
|
|
Setting cache control using aws s3 sync
Warning: Using this option only sets cache headers upon initial sync. The cp command will need to be used to replace headers on existing S3 objects.
|
|