Gzip compression is a technique whereby the server that is loading your content sends over a compressed version of your page that is currently loading. You’ve seen zipped files before, and you have probably had to use some program to “unzip” them in order to bring out all the content. Before it is “unzipped”, all the content is hid away in a small little file. This is what the server does to your page content. Basically here’s how it all plays out:
Such a nice thing to do, right? I would agree. Gzip compression can drastically reduce your page size (up to 75% ish) and optimize your site speed. It is something you definitely want to look into if you haven’t already implemented it on your blog yet.
Now for the dirty work. Let’s look at how we can implement gzip compression on your own blog.
*Note: You need to check with your hosting company to make sure that they allow the use of
mod_deflate – it works better). Many shared server hosting providers will not allow you to use this because of the extra CPU usage it consumes. You will need to call support and ask them if they allow it. If they do, ask them to activate it for you.
Copy and paste this code into your .htaccess file:
As long as the
mod_deflate module has been uncommented on your server, your output will now be compressed in the gzip format. After placing this in your .htaccess, feel free to test your website for gzip compression here. If everything has been done correctly, you should see improved load times on all your pages.
You can also use gzip compression by adding a line of php code to your header.php WordPress file. Copy this code and paste it at the top of your file (right below the introduction text):
<?php ob_start("ob_gzhandler"); ?>
This will also send your content compressed as long as the
mod_gzip module has been loaded on your server. However, I would only recommend this if you can’t use
mod_deflate because this way is not quite as efficient as through .htaccess.