Приглашаем посетить
Набоков (nabokov-lit.ru)

Section 11.1.  Why Use Output Buffering?

Previous
Table of Contents
Next

11.1. Why Use Output Buffering?

Output buffering lets you "send" cookies at any point in your script, ignoring the "headers first" HTTP rule. Internally, it causes PHP to store the cookies separate from the HTML data and then send them together at the end, in the correct order.

Once you are using output buffering, you can compress content before you send it. HTML is made up of lots of simple, repeating tags, and normal text on a site is easy to compress, which means that compressing your pages can drastically cut the amount of bandwidth your site (and your visitor!) uses, as well as how long it takes to transfer a page.

One final advantage is that output buffers are stackable, meaning that you can have several buffers working on top of each other, sending whichever ones you want to output.

Output buffering generally will not affect the speed of your web server by any great amount, unless you choose to compress your content. Compression takes up extra CPU time; however, the amount of page bandwidth you use will be cut by about 40%, which means your server will spend less time sending data across the network. Your compression mileage may varyif you have lots of pictures, this will matter less; if you are sending lots of XML, your savings will be higher.


Previous
Table of Contents
Next