This article is specifically about the Apache "httpd" web-server, but the same advice applies to other web-servers.
While looking into Javascript compressors (minfiers and packers), I bumped into HTTP compression. I knew about HTTP compression, but it wasn't something I'd really thought about.
After a quick read-up at Wikipedia and after scanning a few HOW-TOs, I checked out the web-server that I maintain at my place of work. What do you know, but it (Ubuntu 9.x + Apache2.2) already came with mod_deflate.c enabled and marginally configured.
According to Danny Vogler's advice, I changed the following:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml
</IfModule>
... into this: (modifications in red)
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/javascript application/x-javascript text/css
</IfModule>
The web-server will now attempt to compress Javascript and CSS content-types—if the client's web-browser supports it, of course.
I then turned my browser to an internal reports page, one that uses jQuery, jQuery-UI, and a (custom) jQuery-UI theme. Counting the site's own CSS theming (including media=print stylesheet), there are four stylesheets and four javascript files attached.
With text/html compression already turned on, the whole mess of content came out to 222,745 Bytes (around 218 KB), including pictures. With text/css and application/javascript content-types being compressed, the content came down to 69043 Bytes (67 KB)—only 30% of the original size! ... Yep, it made my day.
No comments:
Post a Comment
Was this tip helpful? Do you have any related experiences?