Enable HTTP compression with Gzip
What is HTTP Compression ?
HTTP compression is a capability built into both web servers and web browsers, to make better use of available bandwidth. HTTP protocol data is compressed before it is sent from the server: compliant browsers will announce what methods are supported to the server before downloading the correct format; unsupported browsers will download uncompressed data. Data is usually compressed with either deflate or gzip modules specific to the server software. –wikipedia
The benefit using http compression is visitor get faster data transfered, the loss is it will increase server resource.
Requirement :- Server running LINUX OS with Apache 1.3+
Instalation on Linux based servers :
We are going to use the Gzip compression here, as this article’s title.
- Login to your server account with root privilege
- Download the Gzip module mod_gzip.so for Apache, you can get this module in SourceForge for free.
- Unzip and move it to apache modules directory (typically “/usr/libexec/httpd”).
- Edit httpd.conf (typicaly on “/etc/httpd/conf/httpd.conf”) and add this code in modules loader section
LoadModule gzip_module libexec/mod_gzip.soAddModule mod_gzip.c
Save the configuration.
- Now, create a file called .htaccess in http directory where you want to appy the Gzip compression, e.g.: public_html/ add this lines in the file :
<IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </IfModule>This will compress all files with html/htm/txt/css/js/php or pl extension.
- Restart Apache
Test and check the mod_gzip installation
- create a php file e.g: i.php and add this line :
<?php echo phpinfo(); ?>
find the text “mod_gzip”, got one ? youhave successfully install mod_gzip. ! - Now, open a page you have created before in the current directory with html / htm / txt /css/ txt / php or pl extension using Firefox with Web Developer plugin.
From the Information menu ->View Document Size
Will look like this :

- Congratulations, now your site should be more faster to download.