You don't want to do that unless you have to. It will slow down the script.Originally Posted by ice
You don't want to do that unless you have to. It will slow down the script.Originally Posted by ice
I would disagree with that statement for three reasons (though it's not necessarily an exhaustive list):Originally Posted by blm126
- By buffering data, the preprocessor can send data to the server in large segments, rather than piecemeal.
- Output buffering allows filters to be applied that might not otherwise be possible. An obvious example is compression. Though it's not necessary to compress output, the benefits typically outweigh any possible performance penalty.
- Output buffering provides the opportunity for the script to determine the content length and set the corresponding Content-Length header. Without this header, the connection must be closed in order to signal the end of the entity. Any further requests must establish another connection, rather than using persistent connections defined by HTTP/1.1.
If anything, the use of output buffering should be common practice, not something to avoid. In fact, output buffering is enabled by default in the recommended configuration to accumulate writes into 4kB chunks.
Mike
In the case of using it to avoid having to correctly place header() calls, however, it could lead to difficult-to-read code, so I would not recommend using it for expressly this purpose.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Surely that's an issue of code design though, not output buffering itself. Of course, if simple language constructs permit the correct and timely sending of HTTP headers then there's no point of explicitly introducing buffering, but the same can be said in any instance where something is used without any tangible benefits.Originally Posted by Twey
Mike
Indeed so. That's what I was trying to point out: that abusing output buffers in this way would likely lead to poor code design.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Ok,I'm confused.I thought output buffering would slow things down because I read this in the php.ini filer.
; 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.
but early it says this
; - output_buffering = 4096 [Performance]
; Set a 4KB output buffer. Enabling output buffering typically results in less
; writes, and sometimes less packets sent on the wire, which can often lead to
; better performance. The gain this directive actually yields greatly depends
; on which Web server you're working with, and what kind of scripts you're using.
So is output buffering faster or slower?![]()
In 90% of cases, faster. Read mwinter's post.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks