How to Compress Webpages to Load Faster
Webpages that loads faster in browsers not only improves user experience, but also helps you in getting a better position in Search Engines. Since the Google Caffeine is rolling out pretty fast in all the Google Datacenters, the page load speed getting more importance along with other SEO tricks. The Google guy Matt Cutts already mentioned this is some videos and interviews. Compressing a page also reduces the bandwidth uses up to 70% to 80% thus cutting down the page load time and server costs while taking very little resource from server.

HTTP Compression Ratio
There are several methods that you can use to compress the pages. I’ll just tell you 3 easiest yet best methods that I use on my websites and blogs.
- cPanel Compression
If you are using Linux Hosting and cPanel, there’s a builtin option to compress output. The option should be under “Software/Services” as Optimize Website.
cPanel Optimize Website
Click on it and you’ll get three options.
- Disabled: Choose this if you do not want cPanel to compress any output. (A very bad idea indeed)
- Compress All Content : Choose this if you want cPanel to compress all the content before sending to visitor’s browsers. Remember, this may cause a problem to display images properly and you should not use it if you offer downloads of compressed files such as ZIP, RAR, TAR etc.
- Compress The Specified MIME Types : Perhaps the best option we can get. It’ll compress files types that we choose. In most of the cases, we just need to compress the HTML, XML, PHP, CSS and Javascript files. So, we will put the MIME Types of those files here separated by space. For example “text/html text/plain text/xml text/css application/javascript” will do in most cases. You can customize it according to your needs.
Click on “Update Settings” and your contents are now compressed to load faster in browsers.
- PHP Cpmpression
There are several hosts who uses their own custom Hosting Control Panel (Like, GoDaddy, DreamHost, Bluehost, Hostgator). You may or may not find any setting to compress the output. This is where PHP Compression comes handy. Please note, you can compress only PHP files by using this method. If you have HTML files, you can rename that to PHP to make it work.You need to edit each file you want to compress and add the below mentioned code at Line 1. (Before DOCTYPE)
- <?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], ‘gzip’)) ob_start(“ob_gzhandler”); else ob_start(); ?>
If you have a common header (Like WordPress, Joomla, Drupal or any scripts), add the line to the top of the header.php file only.
- IIS Compression
To compress output of a IIS Server (Windows Hosting), you need to have an Administrator Account. This method is really long and pretty hard to setup. I’d suggest to use PHP Compression if you are hosting a PHP powered website. Here is a very good tutorial on enabling HTTP Compression on IIS 6.0. The method is almost same on IIS 7.0.
That’s all.


















1 Comment
Trackbacks and Pingbacks