Discussion » Php Speediness

This is a read-only copy. The forum ran on iamcal.com from 2000 until its database was lost in 2016, and this topic was rebuilt from copies saved by the Internet Archive's Wayback Machine. Some replies may be missing.
Posted by Grim..., 10:49, 6th February 2003:
 
I've just found out about the ob_gzhandler command in php. It compresses the information on the page before it sends it, making things faster. An example of how it works is below. It's simple.

My question is: are there any down sides to using it?


<?php

ob_start("ob_gzhandler");

?>
<html>
<head></head>
<body>

<!-- content goes here -->
<!-- content goes here -->

</html>
</body>

<?php

ob_end_flush();

?>
Posted by izb, 11:34, 6th February 2003:
 
By compresses, do you mean it optimizes your HTML to remove unnecessary bits? Cool.
Posted by cal, 11:42, 6th February 2003:
 
yeah - if the client doesn't support gz compression then they are screwed

use ob_gzhandler() instead:
uk.php.net/manual/en/function.ob-gzhandl...


downsides to using gz are:

* pages render slightly slower
* requires more server power


the downsides to using output buffering at all are:

* requires more memory on the server. bad if you have huge pages, and may choke php
* requires more processing on the server
* users don't see half the page if the server is still working on completing the rest of the page
* gets you into the habit of setting cookies and headers wherever you like, which is BAD
Posted by Grim..., 13:34, 6th February 2003:
 
From what I read on the subject, if the client doesn't support gz then the server doesn't try to do it.

And by compress, it doesn't remove anything, I think it actually compresses, like WinZip.
Posted by cal, 15:13, 6th February 2003:
 
what i just said was that ob_start() doesn't detect browsers but ob_gzhandler() does. i linked to the php manual which explains this and explains mostly everything you need to know about php. use it, and don't trust other sites.
Posted by Grim..., 17:41, 6th February 2003:
 
Um... Isn't that what I did in the code up there?
Posted by cal, 19:54, 6th February 2003:
 
hmmf. yes.
Posted by Grim..., 13:36, 7th February 2003:
 
=D