Make your pages load faster with PHP!
Coding, Website Design January 23rd, 2008I am always looking for ways to make my websites faster, and I know that everyone loves a fast website. Lucky for me I stumbled across this PHP function ob_gzhandler().
Basically what it does is compresses your PHP/HTML code every single time a users web browser loads your site. How cool is that?
To use it all you have to do is be using the .php extension on your pages, if you are, lets get it working…
Check Your Server
First things first, we better check our server will let us run it. To do this theres a really easy function in PHP called “PHPinfo”. Just open notepad and make a file with the following code in it, then save as phpinfo.php
<?
phpinfo();
?>
Now save and upload this to your site and go to http://yourdomain.com/phpinfo.php
What you are looking for is “Zlib Support” if it says enabled, we are good to go! Also please check you are running PHP 4.0.6 or higher or this method will not work for you.
How to compress your page!
Now to compress your page all you have to do is put this code before your and tags in your pages, so the top of your code should look like this…
<?
ob_start( 'ob_gzhandler' );
?>
<head>
<html>
And we’re done!!! That was really easy huh?
You should notice a large speed increase in your site, and it will of course also make your site use much less bandwidth. It wont effect any of your images as they are already compressed themselves.
| | Discuss in our Forums |



January 25th, 2008 at 6:40 am
Oh thanks for that !! next give me tips on how to make wordpress load faster
January 27th, 2008 at 7:58 pm
interesting ill give it a try to check if for real loads faster i have so many wordpress
ty
January 28th, 2008 at 1:31 am
Thanx for the info frd… as u can see my site stated in my url ….is made in PHP and sometimes get probs in loading soon …. but now i will try this thing on it and lets c if it helps or not …
keep postin such helpful posts frd… liked the info given on ur blog