s3headersetter is a CLI application for setting the Cache-Control and Content-Type HTTP headers on S3 objects.
The headers and values to apply must be specified in a YAML file.
For example, the following YAML will:
- Set
Cache-Controltomax-age=3600, publicon.htmlobjects. - Set
Cache-Controltomax-age=604800, publicon.cssobjects. - Set
Cache-Controltomax-age=31536000, publicon all other objects. - Set
Content-Typetofont/woff2on.woff2objects.
rules:
- header: Cache-Control
when:
- extension: .html
then: max-age=3600, public
- extension: .css
then: max-age=604800, public
else: max-age=31536000, public
- header: Content-Type
when:
- extension: .woff2
then: font/woff2Release builds for Linux, macOS and Windows can be downloaded from the releases page.
There is no installation process; just put the executable wherever you want.
s3headersetter -config <CONFIG FILENAME> -bucket <BUCKET> (-key-prefix <PREFIX>)For example:
s3headersetter -config config-sample.yml -bucket my-buckets3headersetter -config config-sample.yml -bucket my-bucket -key-prefix wwwThis project uses the following packages:
- github.com/cariad/gos3headersetter to interact with the headers of S3 objects.
This project is published under the MIT Licence.
You don't owe me anything in return, but as an indie freelance coder there are two things I'd appreciate:
- Credit. If your app or documentation has a credits page, please consider mentioning the projects you use.
- Cash. If you want and are able to support future development, please consider becoming a patron or buying me a coffee. Thank you!