Faster website access using Mod_Deflate Compression
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).
Mod_Deflate Installation
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)
mod_deflate.c
root@server [~]#
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.
Enable Mod_deflate
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.
Server Wide
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.
<IfModule mod_deflate.c>
#compress content with type html, text, and css
AddOutputFilterByType DEFLATE text/html text/plain text/css
<IfModule mod_headers.c>
#properly handle requests coming from behind proxies
Header append Vary User-Agent
</IfModule>
</IfModule>
</Location>#Handle old browsers that do not support compression
<IfModule mod_deflate.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
Restart the web server to apply the settings.
Domain wise
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.
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>
#End Gzip
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.
One thought on “Faster website access using Mod_Deflate Compression”
You must log in to post a comment.