Page 1 of 1

Output buffering

Posted: Fri Feb 09, 2007 7:06 am
by methos
According to
the following code is used to "double buffer" when you need to "get content length" and "compress the html" at the same time.

Is "double buffering" needed to accomplish both things or do modern versions of PHP already take this "problem" into account?

Where do I put other headers ? such as:

Code: Select all

header ('Accept-Ranges: bytes');
header('Content-language: en');

Code: Select all

ob_start();
ob_start('ob_gzhandler');

  ... output the page content...

ob_end_flush();  // The ob_gzhandler one

header('Content-Length: '.ob_get_length());

ob_end_flush();  // The main one
What would happen if I did this?

Code: Select all

ob_start();
ob_start('ob_gzhandler');
header ('Accept-Ranges: bytes');
header('Content-language: en');

  ... output the page content...

ob_end_flush();  // The ob_gzhandler one

header('Content-Length: '.ob_get_length());

ob_end_flush();  // The main one

Posted: Fri Feb 09, 2007 7:31 am
by choppsta
I would suggest getting the LiveHTTPHeaders extension for Firefox. This will let you see all the response headers you get back from your server.
http://livehttpheaders.mozdev.org/