Most of the users having issue in  website loading  or load time is very high .Here I am explaining one method to speed up your website. There are several methods to speed up website one of them is Gzip compression and it is most popular method to load fast by compress page size of your site .

Now these days majority of website use  compression , delivering the content at latest browsers , which support compression. It is useful when we use to html text , js , javascript like images already compressed.So it will  bandwidth saving and then website get more responsive.

Here I am explaining how to setup gzip compression  through .htaccess . One module Mod_deflate is an apache module that will be used to compress data using gzip compression

Check mod_deflate is installed and enabled in apache

Mod_deflate apache module will installed by default in apache server . Below is the command to check mod_deflate is installed and enabled .

For Debian Based System :

 apache2ctl -t -D DUMP_MODULES | grep  mod_deflate

For Linux ( CentOS/Red Hat ) :

httpd -t -D DUMP_MODULES | grep deflate_module

 

Output will be like below.

deflate_module (shared)

Syntax OK

How to use mod_deflate ?

To use mod_deflate ,  I am adding few lines in .htaccess file .

Enabling  mod deflate ( Gzip ) Compression in .htaccess

# Put filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Drop some browsers which can create problem.
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

How to test if Gzip compression or mod_deflate is working ?

There are so many sites online which provide to help test whether mod_deflate or gzip compression is working or not .Find below one of the online test url.

http://www.whatsmyip.org/http-compression-test/

Enter the URL and click on the “Test” button.Below is the example of online test snapshot.

mod_deflate_test_techtransit

By Sachin G

I am a professional freelance contributor and founder of tech transit. Love to write and lover of education, culture, and community. I have been using it, setting, supporting, and maintaining it since 2009.Linux rocks! Sachin G Follow me on LinkedIn and x formerly twitter