Enabling Gzip CompressionIn many forums and on many webpages it has been widely proclaimed that to enable gzip compression using php is as easy as adding a single line of code at the beginning of each page. This is not false, however it is not the best way of doing it. Before continuing, here's the code. It takes advantage of Php's buffered output and buffers all output of the script until the Php engine has completed, and then runs all the output through a special function that gzip compresses it before sending it on to the browser. Here is the code. Just place this at the very top of all your Php pages and it will send gzip-compressed output to the browsers.
This method is dependant on the Apache server and in addition, the mod_gzip module must be installed and loaded. Other Methods to Enable Gzip CompressionThe 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) Another method of gzipping is as follows:
|
Friday, July 10, 2009
How to enable gzip compression with Php.
Saturday, July 4, 2009
Subscribe to:
Posts (Atom)