Lighttpd tip: compress your assets

written by zsombor on May 16th, 2006 @ 09:44 PM

Don’t keep the user waiting while your favorite Javascript library are streamed down the wire. Keep the download small and your users will thank you for it! All you need is a simple snippet inside your lighttpd.conf file:

# this assumes that mod_compress is loaded
compress.cache-dir = "/var/lighttpd/cache/compress/"
compress.filetype  = ("text/plain"
                      "text/html"
                      "text/javascript"
                      "text/css"
                      "application/xml")

That’s all folks! Without fussing with risky source altering Javascript compressors. Just let lighttpd gzip the content before transmitting over to the browser. Some results for the Javascript files shipped with rails:

File Size in bytes Compressed
prototype.js 55149 12466
effects.js 32871 7278
controls.js 28036 7246
dragdrop.js 29435 7112


did I say that it works on styleseets too?

Post a comment

Options:

Size

Colors