Compressing your website pages on the server is a great way to improve your site speed overall. One site I manage was six times smaller after I enabled gzip compression.
Most modern browsers support compression of HTML, CSS, and JavaScript files. So if you set up your web server to deliver compressed files the majority of your readers will receive compressed files, greatly improving their delivery speed.
Here's How:
First, make sure that your site isn’t already being compressed by your hosting provider. Some hosting providers automatically compress HTML documents for their customers. To verify, use a tool like GIDZipTest to check your site. If it comes back with "Yes" then you’re done.
Chances are that your pages are not compressed. And in order to compress them you need to have the following:
- Know what server you are running (IIS or Apache or something else)
- Access to your web server configuration
For IIS
If your server is IIS, follow the instructions in Microsoft TechNet document to enable compression.
For Apache
Edit your
.htaccessfile and add the following lines:# compress text, HTML, JavaScript, CSS, and XML
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
# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-AgentAfter you’ve saved the
.htaccessfile, test your site again in GIDZipTest. It should come up as compressed.If It Still Isn’t Compressed
Some virtual hosts don’t always recognize output filters that are loaded in the
.htaccessfile. If your site isn’t compressed after adding those lines, then you’ll need to add them to thevhosts.conforhttpd.conffile for your site.Look for your site in the file and find the line that starts
<Directory>. Then add the above lines into that section of the conf file, above the</Directory>line. Once you’ve saved the file, you’ll need to reload Apache.If it still isn’t compressed or you can’t edit the
vhosts.conforhttpd.conffiles, you’ll need to talk to your hosting provider about turning on compression.
What You Need
- Access to
.htaccessfiles or server administration files

