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.
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
If your server is IIS, follow the instructions in Microsoft TechNet document to enable compression.
.htaccessfile and add the following lines:
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
# remove browser bugs
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
After 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 the
httpd.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
httpd.conffiles, you’ll need to talk to your hosting provider about turning on compression.
What You Need
- Access to
.htaccessfiles or server administration files