s3 site cache optimizer
0.8.2
通过将指纹包含到所有资产的文件名中,优化在 S3 中托管的静态网站。优化后的网站将上传到具有正确缓存标头的指定 S3 存储桶中。
您可以使用以下 pip 命令安装稳定版本:
pip install --upgrade s3-site-cache-optimizer
如果您想跟上最新功能,请安装开发版本:
pip install --upgrade https://github.com/novemberfiveco/s3-site-cache-optimizer/archive/develop.zip
命令行工具执行以下步骤:
所有文件操作都在(临时)输出目录中执行,源目录不变。
资产和可重写文件根据其文件扩展名进行识别。目前,以下文件扩展名被视为资产:
可重写文件是基于文本的文件,具有以下扩展名之一:
如果您想查看添加的其他文件扩展名,请提出功能请求。
usage: s3-site-cache-optimizer [-h] [--debug] [--version]
[--exclude PATTERN [PATTERN ...]]
[-o OUTPUT_DIR]
[--access-key AWS_ACCESS_KEY_ID]
[--secret-key AWS_SECRET_ACCESS_KEY]
[--region REGION]
[--gzip]
[--prefix PREFIX]
[--domains DOMAIN [DOMAIN ...]]
[--skip-s3-upload]
source_dir destination_bucket
positional arguments:
source_dir Local directory containing a static website.
destination_bucket S3 bucket name.
optional arguments:
-h, --help show this help message and exit
--debug Enable debug output
--version show program's version number and exit
--exclude PATTERN [PATTERN ...]
Exclude files and directories matching these patterns.
-o OUTPUT_DIR, --output OUTPUT_DIR
Output directory in which local files are written.
When absent a temporary directory is created and used.
--access-key AWS_ACCESS_KEY_ID
AWS access key. If this field is not specified,
credentials from environment or credentials files will
be used.
--secret-key AWS_SECRET_ACCESS_KEY
AWS access secret. If this field is not specified,
credentials from environment or credentials files will
be used.
--region REGION AWS region to connect to.
--gzip Gzip text-based files.
--prefix PREFIX Subdirectory in which files are stored in the bucket.
Stored in the root of the bucket by default.
--domains DOMAIN [DOMAIN ...]
Domain names on which the site will be hosted.
--skip-s3-upload Skip uploading to S3.
$ s3-site-cache-optimizer ~/srv/www.example.com www.example.com --access-key XXXXXNOVEMBERFIVEXXXXX --secret-key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$ s3-site-cache-optimizer ~/srv/www.example.com www.example.com --exclude ".git/*" ".git*" --region eu-west-1
$ s3-site-cache-optimizer ~/srv/www.example.com www.example.com --output ~/srv/example-optimized/ --skip-s3-upload
$ s3-site-cache-optimizer ~/srv/www.example.com my_bucket --domains www.example.com example.com --prefix "user/sites/www.example.com"
s3-site-cache-optimizer 是根据 MIT 许可证发布的。