Here’s a tidbit of code for you, in a hope that this helps someone out. Paste the following into your .htaccess file and it will enable GZIP across all pages in the directory where the .htaccess file resides:
php_value output_handler ob_gzhandler
Hows it do it?
This line of code sets the output handler/buffer as ob_gzhandler which autosets the ob_start() function to “ob_gzhandler” so the code doesn’t have to be entered. Normally you would have to enter this in the PHP to do GZIP Compression:
// In the head:
// At the bottom:
What is GZIP?
GZIP is a very effective way of keeping your bandwidth down when having large HTML/PHP pages. What it does is it compresses the page that’s being sent to the user viewing your site. When the user recieves this compressed version of the page it uncompresses the page on their end with the browser displaying it in full to them.
But how much does this effect the user?
The user gets a faster page and it doesn’t effect them in any other way.
And what about my server?
Your CPU usage will go up slightly for a time but then it will return to normal after 30 minutes or so of users hitting your page and the server has cached gzipped pages.
How much of a difference does it really make?
The answer, is roughly 80-90% of your raw code file being sent to the user is removed.
A good implementation case study for this is Pixel2Life. Before GZIP it had a 160kb file output and after a 14kb file output. That’s a fantastic reduction in overall download size.
GZIP does not compress images, just the raw HTML/CSS/JS code from the site being sent to the user.