Null Disquisition

Lots of talk about nothing

Serve gzipped content from Amazon S3

Media_httpmumrahdotne_aeukj
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.
  1. http://mumrah-dot-net.s3.amazonaws.com/gziptest.txt.gz
  2. http://mumrah-dot-net.s3.amazonaws.com/gziptest.txt
  3. 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

Filed under  //   Amazon Web Services   aws   gzip   s3  
Posted May 5, 2009