Compressing webpage content for faster page loading
There are many ways of how to compress your web page content, that is outputted to end user's browser. Most popular are: using apache mod_gzip or mod_deflate, using zlib compression or using ob_gzhandler. There are many opinions on which is better and probably there are no right answer, and since combined usage of this methods is not recommended or even prohibited, you'll just need to test what suits your website best, based on many factors, like compression rate, CPU load and of course ability to implement, because many hosting companies may restrict or force some compression options.
Zlib compression can be enabled through php.ini files or in .htaccess file. Although it is stated that zlib.output_compression is PHP_INI_ALL changeable , it doesn't compress if you enable it at runtime in php script. So if you don't have access to your php.ini, then just create .htaccess file with this content:
php_flag zlib.output_compression on php_value zlib.output_compression_level 9
And last is ob_gzhandler, which is easily used as a callback function of standard output buffering:
<?php ob_start("ob_gzhandler"); echo "Content that will be compessed"; ob_end_flush(); ?>
You may also be interested in:
Powered by BlogAlike.com