I use gzip compression for Amazon S3. I gzip HTML, JS, CSS files and keep images unchanged.
I sync everything using s3cmd:
s3cmd sync --cf-invalidate ./deploy s3://n12v.com
Unfortunately, this doesn’t set Content-Encoding: gzip
to all necessary files.
I need to find all updated gzip files and set Content-Encoding: gzip
for each one of them. The best solution I could came up with:
- find all gzipped files by running
gzip --test filepath
on every one s3cmd put --add-header='Content-Encoding: gzip' filepath s3://n12v.com/filepath
, e.g. upload files again just to add a header.
This is very ad-hoc solution, is there any better ways of doing this?