If you are new to php or a seasoned veteran and aren’t utilizing the gzip compression features of php, you could be missing out on a lot of traffic. Did you know that you could be losing traffic before they land on your page because the page takes too long to load? That is a fact! According to market research, people will click away before they actually arrive because a page takes too long to load!
Fellow php coders and newbies, there is a way to keep your site’s visitors by decreasing the load time of a page significantly. You can turn on gzip compression that works just like WinZip or other software that archives files on your computer. It only takes a single line of code but it has to be read first, so if you are using WordPress you would put this in the top index file. If you are using oscommerce, this would need to go in the application top file in the includes folder. For custom scripts, simply place this as the first line of code read by the server.
Here is the code:
<?php
ob_start('ob_gzhandler');
?>
Now this will make the server load all pages faster. But, it is set at a default setting of 6 which still can slow things down a bit. In order to increase the compression, you have to define it. The compression is on a scale of 1 to 9, 9 being the highest compression. Please note that if you are running on a sluggish server, increasing the compression size can knock the server down and send your website down. Be sure that you are indeed using a good webhost before increasing your gzip compression.
To increase the compression and activate gzip, put this line of code on the first file your server reads:
<?php
ini_set('zlib.output_compression_level', 9); ob_start('ob_gzhandler');
?>
I hope this helps you keep your site’s visitors and wish each and everyone of you success! If you are worried that your webhost isn’t up to par, I recommend this host!
