WELCOME

This blog is where I post about my consulting work with Microsoft Technologies, and other random tidbits that don't fit in my Photo Blog or my Iraq Blog.

Wednesday, September 22, 2010

Great tip on serving compressed CSS and Java Script files from Amazon S3

Fantastic performance tip on hosting compressed CSS and javascipt file from Amazon S3:

"Typically, I use a tool called Juicer ( http://github.com/cjohansen/juicer) to concatenate and compress my CSS and JavaScript files (with YUI Compressor and Google Closure Compiler, respectively) to ensure they're as small as possible and require the fewest number of HTTP requests ( http://developer.yahoo.com/performance/rules.html#num_http).

After that, I launch Terminal and run `gzip -9 filename.css && gzip -9 filename.js` to compress them as tightly as possible. This will give me filename.css.gz and filename.js.gz. I remove the .gz extension, and upload those files to S3.

Lastly, I add a custom HTTP header — `Content-Encoding: gzip` — to each of the files in S3. This tells the browser the same thing as Apache would if it were compressing them on the fly. The browser then knows to decompress the content after downloading it.

Since the files are pre-compressed instead of compressing on the fly (a la Apache), fewer server resources are used and the response times are faster. "



Original source: http://developer.amazonwebservices.com/connect/thread.jspa?messageID=194918&tstart=0#194918

No comments: