Portal Home > Knowledgebase > Working on Your Website > Compressing Web Pages for Faster Load Times


Compressing Web Pages for Faster Load Times




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.

 

Keywords- Webpage compression, gzip compression, speed up your website with compression



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Custom error pages (Views: 2870)

Powered by WHMCompleteSolution