The Beauty Of Speed

While perusing the excellent Website Analyzer tool to check loading speeds, and filesizes of certain elements, I saw that this site could use some optimization, even though I tried to keep everything to a minimum (images, CSS, etc.) Then I remember you can gzip pages server-side, and serve it to visitors compressed, thus increasing speeds by up to 2 times.

To which this useful tool come into play. It lets you know if your site is compressed using gzip, and if not, what benefits you’ll receive if enabled. So I went looking around, and found that if I put this at the top of my documents, it’ll enable the PHP module, zlib, for compression of that particular page:

<?php ob_start("ob_gzhandler"); ?>

Which is a good idea if you have a php-based script that already has it’s own compression technique (phpBB comes to mind), or if you want to compress individual pages of your choosing.

Additionally if you just want to globally compress your whole site, then you can use a .htaccess file and put in this command to force a switch on the server everytime your site is accessed:

php_flag zlib.output_compression On

The above code I put on my other site, 3DGPU, since it’s a lot bigger, and for some reason the CMS we’re using, Xoops 2, doesn’t enable gzip support when we tell it to. I had just assumed it worked, and found out yesterday it doesn’t, so I put in the .htaccess file with the command above, and voila; 65kb HTML compressed to 17.5kb. A 99% compression ratio! GB! went from 40kb to 8kb, a 77% compression ratio. Now both and loads up in a jiffy.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>