Speed up your website using gZip compression

 David

Most modern browsers support gzip compressed http response so just by enabling this in your Apache configuration, your website will have significant performance improvement.

Why send the html, css, and javascript files in plain text when they can be compressed down to much smaller sizes so that response network traffic will be smaller, making the website content load faster!

Check out how my website response size changed after I enabled the gzip compression!

As you can see from above, the handymango.com html content went from 44.9 KB down to 6.8 KB. That's about 85% reduction in size!
Similarly, my main.css file went from 59.7 KB down to 8.9 KB.

The best part is that you don't have to do any programming or change the website contents to take advantage of this. You can simply enable/install the apache modules and add few lines to the .htaccess file and it will take care of the compressed http response by itself as the gzip compression is requested by the modern browser and if your webserver is configured to support it then it will automatically send the compressed http response that the browser can unzip before rendering it!

So, how do you enable this on your website?

First, you will to enable two modules on your Apache webserver. If you have access, you can uncomment the following two lines in httpd.conf file or if you don't have access to that file then you can ask your hosting support team to install/enable the modules below:

LoadModule filter_module modules/mod_filter.so
LoadModule deflate_module modules/mod_deflate.so
Lastly, you need to add the following lines in .htaccess file

# compress text, html, javascript, css, xml:
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/opentype
    # For Olders Browsers Which Can't Handle Compression
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

That's it! Now your website will load faster... go take a break and enjoy a
Go Back to List Page

Leave a comment

Name : Comment : view emoticons
Please consider signing up for our website.
If you sign up and log in:
  •   You can avoid the "I'm not a robot" captcha when commenting
  •   You can also avoid typing your name every time
  •   You can upload a picture for each comment
  •   You can change or delete your comment within 1 hour
  •   You can track all the comments you posted on this site
  •   You can read blog posts that are only open to members
  •   You can look up blogs using the search feature
  •   More privileges for our friends & families coming...

OK, Sign me up!

Emoticons are a great way to visually express how you feel.
However, there are times when unintended content is converted to emoticon because the content happens to have one of the emoticon symbols. That's why it's always good idea to preview your comment before posting and when you see this type of problem, you can indicate NOT to auto convert.