amazon s3 - Set content-encoding to specific files via aws command -
i deploy static application aws command. copy files folder s3 bucket command :
aws s3 sync c:\app s3://mybucket
i want set content-encoding gzip js,jpg,and html files. succeed folder command : --content-encoding gzip
how can specific files type ?
this old, needed find way this: i'm not using cloudfront, , proxy using doesn't handle gzip... so:
- exclude files
- include individual file types needed
- set appropriate encoding/options
below i'm adding access control , cache-control, , deleting files in s3 not present in local directory
i've separated js/css of images, html not necessary.
i did have lot of trouble not explicitly setting content-encoding/cache each individual --include, i've set below make clearer.
the aws docs find don't mention of stuff
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 \
pretty neat little speed improvement serving s3.
Comments
Post a Comment