Compression is a simple, effective way to save bandwidth and speed up your website in Linux Shared Hosting. By adding a piece of PHP code to the top of your Web pages, you can instruct the Web server to compress files for transit to your visitors’ Web browser. This is especially useful for text-heavy Web pages that are over 100K in size.

To Optimize Your Site Using Compression
Add the following code to the very top of your Web pages above the DOCTYPE:

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

Rename the file you want to compress with a .php extension instead of .html or .htm and upload the file to your site. The file will be compressed upon request and delivered to the visitors’ browser.

Post By Editor (2,827 Posts)

Website: →