• View our reviews on Hot Scripts
  • JS Tutorial

Recent Comments

Powered by Disqus

Back to articles

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.

So let's start with apache. Implementation of compression through apache varies based on apache versions. If your server uses apache version 1.3, you will be able to compress content using mod_gzip while apache version 2.x uses mod_deflate.

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:


echo "Content that will be compessed";


You may also be interested in:

Powered by

blog comments powered by Disqus