Compression

Although Compression is a very important method of making your pages lighter and easier for users to download, it’s definitely going to cost you more CPU and on high load servers it’s not recommended.

Mod_deflate

Older versions of apache supports mod_gzip module for content compression. Latest versions of apache supports mod_deflate module for content compression. Both are having same functionality. But with mod_deflate we can optimize the website through cPanel/WHM.

Enabling mod_deflate, will increase cpu usage and may slow down sites especially in cases if visitors are using high speed internet connections. The mod_deflate might be useful if site’s target audience is using dial-up or similar low speed connection to the internet.

While comparing with mod_gzip, mod_deflate is better. Please update us, if you want to install mod_deflate.

You can see the option “Optimize Website” option only if mod_deflate is installed in your server. You can compress all the contents of your site or a particular type of contents using that “Optimize Website” option.

By default compression will be disabled, after the installation of mod_deflate. Each cPanel user has to change the settings to optimize the websites or the root user has to enable compression of the all the cPanel accounts in the WHM, by logging into the cPanel as a root user. More details here.

GZIP compression

This is highly recommended as it doesn’t need any code and generates Gzipped HTML which almost all today browsers can understand. You need to change/add these values on your php.ini

zlib.output_compression = On
zlib.output_compression_level = 9

For PHP Compression you can easily compress the files by adding the following code to the top of any PHP file needing compressed.

if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')){
ob_start("ob_gzhandler");
}else{ 
else ob_start();
}
?>

What this does is, it checks if the browser requesting the website supports compression, if it does it compresses the data, and if not, it just sends the content normally (uncompressed). This method will only compress content loaded into the PHP file.

With the help of a good developer you can reduce the size of the files and optimize it.