Jump to content
Larry Ullman's Book Forums

Chapter 18 Question About Output Buffering


Recommended Posts

hi guys :D!

 

i have question about output buffering(chapter 18 page 561)

 

i have searched google about it and it came with alot of debates, some say its good practice, some say its bad practice to use it, but they dont provide any code for testing why its good and why its bad..

 

so the question is :

is it a good practice to always use it ? as Larry's statement in the book that says

"There can be a performance improvement with output buffering, but the main benefit is that it eradicates those pesky headers already sent error messages."

 

if its bad practice, please give good reasons + codes(if neccessary) to prove why its bad

Link to comment
Share on other sites

Here's a decent SO link on the topic:

http://stackoverflow.com/questions/2832010/what-is-output-buffering

 

I personally don't like it in most cases, as everything I've ever read suggests that most users using the displaying of a page in pieces as the main indicator that the page is actually being loaded. As such, if you wait to output the whole page at once, users might have to stare at a blank white screen for a while, thus causing them to wonder what is taking so long, which in turn may lead to them giving up and clicking the back button.

It should be noted that this problem is exacerbated even more on mobile devices, which generally take longer to load pages.

Link to comment
Share on other sites

I personally don't like it in most cases, as everything I've ever read suggests that most users using the displaying of a page in pieces as the main indicator that the page is actually being loaded.
HartleySan, would you confirm that it is a personal dislike of this output buffereing as opposed to bad practice to use it. Generally I don't use ob, but find it helpful to use in cms scripts which give the user options to edit/delete/insert content and then redirect to an appropriate page depending on the selected option. If there is a better approach, I would be interested to learn it.
Link to comment
Share on other sites

I don't have any links handy, but most web design best practice articles say that you have about 2 seconds on average to show the user something or they will leave. That means that if a user sees only a white screen for 2 seconds, they'll likely hit the back button. Using output buffering greatly increases the odds of that happening.

Plus, as I said, I personally don't mind seeing the page load in pieces. I personally prefer that over waiting and waiting, and then suddenly, bam!

Link to comment
Share on other sites

I'm not sure that output buffering in PHP adversely affects the performance of loading the Web page in the browser. I've not seen that written anywhere and of the things that happen when a user requests a page, I don't think that's a significant component. And output buffering should increase PHP's performance. And output buffering is enabled by default on most servers, so we're probably all seeing output buffering in action most of the time (for PHP pages).

 

HartleySan, you're suggesting a direct correlation to PHP's output buffering and how the browser renders an HTML page. I could be wrong, but I don't think one exists.

Link to comment
Share on other sites

 Share

×
×
  • Create New...