PHP compression using gzip

The best way to compress PHP files is to use

auto_prepend_file

Add the filling code to a file called gzip.php

<?php

    if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'))

        ob_start("ob_gzhandler");

    else

        ob_start();

?>

Then update your php.ini files as follows

auto_prepend_file= /path/to/gzip.php

you can also use a htaccess file if your server permits

php_value auto_prepend_file gzip.php

Testing the compression

More detailed information on compressing files

January 10, 2010 Post Under PHP - Read More

Comments are closed.