Instructions on how to enable gzip compression on a Php webserver.

This is part of a collection of information about Information About The Internet,
which is part of my web collection of information.


Enabling Gzip Compression

It has been widely proclaimed in many forums and accross the internet at large that to enable gzip compression on a php page is as easy as adding a single line of code at the beginning of each page. I will not contend that this statement is false. Before going on, here is the code. It takes advantage of Php's buffered output and buffers all output of the script until the script has completed, and then runs all output through a special function that compresses it before sending it to the browser.

Here's the code. Just place this at the very top of all your Php pages to send gzip-compressed output to the browsers.

<?php ob_start("ob_gzhandler"); ?>
This method is dependant on the Apache server and additionally the mod_gzip module must be installed and loaded.

Other Methods to Enable Gzip Compression

The method mentioned above is quick and easy, but the downfalls are that it only works on Apache with mod_gzip. Not only that, but according to the Php manual, that is not the preferred method for gzipping.

(From the Php manual at www.php.net)
note that using zlib.output_compression is preferred over ob_gzhandler().




Contine browsing the collection of information about Internet Information,
or return to my web collection of information.


This entire website and all contents are copyright 2004 www.reliply.org