This Site is Now Compressed!

When I was hosting this site on my own server at home, I had mod_gzip and mod_deflate installed. But since I switched to a 3rd party host (modhost — great host by the way… cheap too!) I no longer had the ability to compress my HTML before it went out to a user’s browser.

By the way, for those of you who don’t know what I’m talking about, compressing your pages before it streams to the browser can increase the speed of your page load time for users on slower connections. The size of an HTML page can go down quite a bit — this page went from around 30kb to ~7kb after it’s been compressed.

Without mod_gzip or mod_deflate, what’s one to do? Well, luckily, my pages are written in PHP. PHP has a function (ob_gzhandler) that will compress your page for you. The nice thing about ob_gzhandler is that it first determines what type of content encoding the browser will accept (”gzip”, “deflate”, or none at all) and will return it’s output accordingly. So, by enabling this, all browsers are still supported. Below is an example of how this works:

This should be a compressed page.

3 Responses to “This Site is Now Compressed!”

  1. pat reardon Says:

    also i’d love to find out more about this!!! any sites to suggest?

    thanks!
    pat

  2. brewthatistrue Says:

    http://leknor.com/code/php/view/class.gzip_encode.php.txt

  3. David Says:

    What I would like to know/have is the script(s) that allows the image browsing –the one you are using on your banner header. Care to share? Please!

Leave a Reply