PHP compression using gzip

Published by

Posted on January 10, 2010

The best way to compress PHP files is to use


Add the filling code to a file called gzip.php

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
curl -I -H ‘Accept-Encoding: gzip,deflate’
More detailed information on compressing files