我通过aws命令部署静态应用程序。我通过以下命令将文件夹中的所有文件复制到s3桶:
aws s3 sync C:\app s3://myBucket我希望将内容编码设置为gzip,仅设置为js、jpg和html文件。通过以下命令,我成功地对所有文件夹执行了此操作:--content-encoding gzip,如何仅针对特定的文件类型执行此操作?
发布于 2017-06-02 10:41:58
这是旧的,但我需要找到一种方法来做到这一点:我没有使用Cloudfront,而且我们使用的代理不处理gzip.因此:
下面我还添加了访问控制和缓存控制,并删除了s3中没有出现在本地目录中的任何文件。
我已经将JS/CSS从所有的图片( html )中分离出来,但这可能不是必要的。
但是,我确实遇到了很多麻烦,因为我没有显式地设置内容--每个个体的编码/缓存--包括,所以我将其设置如下,以使其更加清晰。
我能找到的AWS文档--不要提这些东西
aws s3 sync ./dist/ s3://{bucket} \
--exclude "*" \
--include "static/*.ico" --acl "public-read" --cache-control no-cache \
--include "static/*.png" --acl "public-read" --cache-control no-cache \
--include "*.html" --acl "public-read" --cache-control no-cache \
--include "static/img/*.svg" --acl "public-read" --cache-control no-cache \
--delete \
aws s3 sync ./dist/ s3://{bucket} \
--exclude "*" \
--include "static/js/*.js" --acl "public-read" --cache-control no-cache --content-encoding gzip \
--include "static/css/*.css" --acl "public-read" --cache-control no-cache --content-encoding gzip \
--delete \ 对于只从s3提供服务的人来说,速度上的改善是非常简单的。
https://stackoverflow.com/questions/27165946
复制相似问题