Everyone wants a faster website. In fact, website performance is one of the key attributes used by Google when turning up search results. If a page takes longer than 4-5 seconds to load, most web surfers today abandon it and move to another site. One of the most powerful methods of serving your site faster is to incorporate GZIP compression.
What is GZIP Compression?
In a nutshell, GZIP compression allows your website to compress large files before sending them to your visitor. Smaller files transfer quicker, and the visitor’s web browser simply unzips them on the receiving side. GZIP compression can shink the network traffic needed to view your website by as much as 80%!
How about Mod Deflate?
Mod Deflate is another compression scheme similar to GZIP.
Are You Using GZIP?
Depending on your web host, you may have GZIP enabled and not even know it. Before making changes, test your website URL at WhatIsMyIp.org. If the tool returns that you’re using compression, then there’s nothing else for you to do (unless you want to try different compression types). If the tool shows no compression on your website, keep reading…
Enable GZIP Compression
In some cases, you’ll have to ensure that your host has one of these compression methods available. Typically, if you access your hosting account using CPanel, you can check the Optimization menu to make sure your account is set to compress all files. After that, you’ll still have some work to do in your .htaccess file. You might have to check with your host just to be sure.
For Apache Servers:
Add the following line to your .htaccess file:
Alternatively, you can add this block of code if you expect significant traffic from older browsers:
<ifmodule mod_deflate="" c="">
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml</ifmodule>
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0 no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
For Servers using NGINX
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
If your site happens to be running on IIS (a Windows-based web server), then follow these instructions for enabling GZIP.