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:

  1. exclude files
  2. include individual file types needed
  3. 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

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -