Enabling gzip compression in your site

I keept hering about gzip compression but I never gave it much attention, it turned out that enabling gzip compression for your html pages (and .php, .js, etc) can decrease file size usually by 50-70%, this means that your page will double the speed of your site.

Studies show that users tent to spend more time on more responsive sites and conversions are better on more responsive sites.

Basically your apache server compresses the file before sending it to the user browser.

Here is how to enable gzip compression, if you have Plesk control panel installed then your domain has a path similar to this:

/var/www/vhosts/[DOMAIN NAME]/conf/

If there is only a file called httpd.include there, have a look inside it, if there is a warning not to edit it, then don't and create this one instead: vhost.conf, otherwise just edit httpd.include.

Contents should be like this, remember to edit your domain name in this code:

<Directory /var/www/vhosts/photoshopfiles.com/httpdocs>

# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images and some more files
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|swf|zip|flv|mp3)$ no-gzip dont-vary

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

</Directory>

Some file types listed inside that code need to be skipped from compression, this is because with mp3 files for example you might notice straming issues, same with flv, so we do not compress these ones. Zip files should most probably also be skipped (already done above).

With my server setup the gzip didn't activate instantly, not even after an apache restart, I had to go to hosting setup for that domain, I unchecked the ssl support, saved settings, then re-enabled it and saved settings again, then gzip was enabled. I am not sure if it is because of ssl settings or it just needs a cycle to re-initiate some settings.

If you are not sure if you enabled/disabled gzip compression for your site, then do a search for "HTTP Compression Test", there are several sites that ask for your url and does a quick test.