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 許可證發布的。