s3-sync has the ability to receive headers as arguments and pass them to AWS S3 as metadata headers. This modification proposes to set headers at configuration so they are written in the objects when deploying. Main motivation is to be able to pass CacheControl header and have Cache-Control set for objects ovoiding "Leverage Browser Caching" throwed by page speed analyzers. Attention: Metadata are written equal to all objects (files) stored to S3 and there is no way to tailor it by file type at this moment. Signed-off-by: Josenivaldo Benito Jr <jrbenito@benito.qsl.br>
50 lines
1.3 KiB
Markdown
50 lines
1.3 KiB
Markdown
# hexo-deployer-s3
|
|
|
|
Amazon S3 deployer plugin for [Hexo](http://hexo.io/)
|
|
|
|
## Installation
|
|
|
|
``` bash
|
|
$ npm install hexo-deployer-s3 --save
|
|
```
|
|
|
|
## Options
|
|
|
|
You can configure this plugin in `_config.yml`.
|
|
|
|
``` yaml
|
|
# You can use this:
|
|
deploy:
|
|
type: s3
|
|
bucket: <S3 bucket>
|
|
aws_key: <AWS id key> // Optional, if the environment variable `AWS_KEY` is set
|
|
aws_secret: <AWS secret key> // Optional, if the environment variable `AWS_SECRET` is set
|
|
concurrency: <number of connections> // Optional
|
|
region: <region> // Optional, see https://github.com/LearnBoost/knox#region
|
|
headers: <headers in JSON format> // pass any headers to S3, usefull for metadata cache setting of Hexo assets
|
|
```
|
|
#### Example: header Cache-Control
|
|
|
|
``` yaml
|
|
deploy:
|
|
type: s3-cloudfront
|
|
bucket: my-site-bucket
|
|
cf_distribution: mydistributionid
|
|
headers: {CacheControl: 'max-age=604800, public'}
|
|
```
|
|
|
|
This will set "Cache-Control" header in every file deployed to max-age 1 week. This solves "Leverage browser caching" on most page speed analyzers. For custom metadata use:
|
|
|
|
``` yaml
|
|
headers: {Metadata : { x-amz-meta-mykey: "my value" }}
|
|
```
|
|
|
|
## Contributors
|
|
|
|
- Josh Strange ([joshstrange](https://github.com/joshstrange); original implementation)
|
|
- Josenivaldo Benito Jr. ([JrBenito](https://github.com/jrbenito))
|
|
|
|
## License
|
|
|
|
MIT
|