Thursday, December 11, 2008

Php - Make Php / Html load fast using compression

Make Php / Html load fast using compression
This is a little trick to compress PHP files when transmitted from web server into web browser using standard PHP functions. This method will save bandwidth and increase your web speed.

First method, using zlib extension.
You can only do this if your web server support zlib extention.
Php code
'zlib.output_compression',1);
ini_set('zlib.output_compression_level',9);

/* start your script below */






Second method, using ob_start() function. Call ob_start() function with ob_gzhandler will compress the output. Just call this function on the top of every script you have.
Php code
('ob_gzhandler');

/* put any code below */

No comments: