There are many reasons for a website to run slow one of them is heavy content i.e. the website content received by client (browsers) is larger in size and on slower connections this could be a nightmare. Now using Mod_Deflate you can compress the size of files before delivering it to clients. Mod_Deflate is based on a class of data compression algorithms called Deflate that allows the exact original data to be constructed from the compressed data. Mod_deflate drastically reduces/compresses the files which are sent to Client (you can imagine the speed to load 26KB file instead of 120KB of your website).
Before You start using Mod_Deflate you need to check its installed on web server or not. If you have root level you can check that by using command “httpd -l” which lists all the modules which are compiled with Apache Web Server. (shared server users will have to contact their hosting company to check)
Or you can check the httpd.conf and try search for following rule in LoadModule
If you won’t find mod_deflate using above steps Apache is not compiled with mod_deflate, please contact your Webhosting company to re-compile the Apache with it. If you have Cpanel server with root level access you can recompile Apache with mod_deflate using EasyApache.
Mod_deflate can be enable for the complete server were all the websites hosted on the server will be compressed automatically or you can enable is for specific websites using .htaccess only.
If you have the root access of the server add following lines in httpd.conf file of your server which will enable the mod_deflate server wide.
#compress content with type html, text, and css
AddOutputFilterByType DEFLATE text/html text/plain text/css
#properly handle requests coming from behind proxies
Header append Vary User-Agent
</Location>#Handle old browsers that do not support compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0 no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
Restart the web server to apply the settings.
This is very useful for shared hosting customers where they can’t have the root level access.
Now go to home directory of the domain and open (if exists) or create a new file named .htaccess and add following line.
Once its configure now its time to check if its working or not; browse http://www.whatsmyip.org/http_compression/ and enter the website hosted on the server to test.