Skip to content

Instantly share code, notes, and snippets.

@philfreo
Created July 30, 2012 17:52
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save philfreo/3208678 to your computer and use it in GitHub Desktop.
Gzip files in a directory, upload it to s3 for Cloudfront (far futures)
# imgs don't need to be gzipped
s3cmd put -c config/.s3cfg-prod-static --acl-public --guess-mime-type --add-header "Cache-Control:public, max-age=31536000" -r static/img s3://my-bucket-name/
# js/css does need gzipping
rm -rf static/built-gz;
cp -a static/built/ static/built-gz/;
find static/built-gz -type f | while read -r x; do gzip -9 -c "$x" > "$x.gz"; mv "$x.gz" "$x"; done;
s3cmd put -c config/.s3cfg-prod-static --acl-public --guess-mime-type --add-header "Cache-Control:public, max-age=31536000" --add-header "Content-Encoding: gzip" -r static/built-gz/ s3://my-bucket-name/built/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment