Recently, we wrote an article which outlined 32 things that webmasters can do to speed up their websites. One item that we mentioned was the use of GZIP compression to speed up the delivery of web pages. Most people, however, hadn’t heard of GZIP, so we were contacted for methods to add it to websites.
In this article, we show how to use GZIP with PHP on a Linux Apache web server.
Most web hosts compile PHP with support for GZIP. In fact, we have yet to find a Linux web host which does not support GZIP compression.
If you are in doubt about your web host, simply contact them and inquire about GZIP.
Adding GZIP to your website is very simple. In fact, all you have to do is add one simply line of code to your php pages.
The code snippet below needs to be placed as the first line in your document, before any other code.
<?php ob_start("ob_gzhandler"); ?>
And that’s it. Now your web pages will be served more quickly.
You might be wondering how that little line of code can make your web pages more efficient. And given that it is a PHP function, you might wonder why the added processing time does not affect the page load. However, GZIP is proven effective.
If you are skeptical, consider using a service such as WebOptimization.com to compare your load time before and after compression
More information about GZIP can be found in the PHP.net manual.
Tags: compression software, gzip, load timeTrackback URL for this entry:
http://www.velvetblues.com/web-development-blog/how-to-use-gzip-with-lamp/trackback/
Contact us today for a quote. Click here to submit details regarding your project.
If you are making a general inquiry, send an email to info@velvetblues.com