PHP Newbie: Does ob_start()/obflush() improve performance or add overhead? Logically I would assume that ob_start() improves performance, but then wondered if that is the case then why isn't this the default behavior of PHP?
Use of the output buffering functions does increase overhead. The web server must store the entire buffered data in memory until the output is sent to the user.
But here's the comment from php.ini on the output_buffering runtime configuration directive:
[tt]; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On', as
; a value for this directive (e.g., output_buffering=4096).[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.