Archive for the ‘gzip’ tag
Serve gzipped content from Amazon S3
Set the “Content-encoding” header to “gzip”. Really, it’s that easy.
Kthxbye.
Well, since you came all this way, I’ll give a little more detail. First, make a file.
Now gzip it.
Upload it.
Find a utility that can modify file headers on S3: S3Hub (OS X), Cloudberry S3 Explorer (Windows), or any of the various 3rd party libraries.
Set the Content-type header to whatever the appropriate content type is: text/plain, text/css, text/javascript, image/jpeg, etc.
Set the Content-encoding to gzip.
Pat yourself on the back.
Here’s three versions of a text file I made and gzipped. Note that with appropriate headers, file extensions don’t mean squat.
- http://mumrah-dot-net.s3.amazonaws.com/gziptest.txt.gz
- http://mumrah-dot-net.s3.amazonaws.com/gziptest.txt
- http://mumrah-dot-net.s3.amazonaws.com/gziptest
Go ahead and download one – you’ll see that the file is actually gzipped and your browser is doing the deflating on the fly. This is the same effect producted by mod_deflate in Apache.
-David