[Cialug] gzipped js and css with no app server

Matthew Nuzum newz at bearfruit.org
Thu Jan 17 21:17:54 CST 2008


It's trivial to write a bit of PHP code that looks at the http
accept-encoding header and choose to send either compressed or uncompressed
data based on what you find there. However I'm in a special situation where
I cannot serve dynamic content based on individual browser settings. I have
a caching proxy in front of the app server and for performance reasons we
don't send differing content based on browser preferences.

I've been trying to figure out a way to detect if gzip compression is
supported on the client side and then use that information to request either
compressed or uncompressed js and css files.

The difference in file size really is impressive, starting at about 50%
decrease in file size for small resources and improving to 70% decrease in
file size as the resources get larger. Also, it allows you to use normal,
non-packed js files with practically no difference in download size which
makes debugging js *so* much easier. (by packing I mean something like
http://dean.edwards.name/packer/)

I've come up with a solution. It adds about 1.4k to the page weight, but in
my use case saves over 20k. I've got a working example but would really
appreciate a few extra eyes and any feedback. I've documented my proof of
concept here and I'd love to hear your thoughts on it:
http://www.bearfruit.org/blog/2008/01/17/using-gzip-compressed-js-and-css-without-an-app-server

-- 
Matthew Nuzum
newz2000 on freenode
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cialug.org/pipermail/cialug/attachments/20080117/79dc8feb/attachment.htm


More information about the Cialug mailing list