PHP Flush that works… even in Nginx

The easiest way to eliminate nginx’s buffering is by emitting a header: header(‘X-Accel-Buffering: no’); This eliminates both proxy_buffering and (if you have nginx >= 1.5.6), fastcgi_buffering. The fastcgi bit is crucial if you’re using php-fpm. The header is also far more convenient to do on an as-needed basis. Docs on X-Accel-Buffering Docs on fastcgi_buffering

How to prevent BrokenPipeError when doing a flush in Python?

The BrokenPipeError is normal as said phantom because the reading process (head) terminates and closes its end of the pipe while the writing process (python) still tries to write. Is is an abnormal condition, and the python scripts receives a BrokenPipeError – more exactly, the Python interpreter receives a system SIGPIPE signal that it catches … Read more

php flush not working

So that’s what I found out: Flush would not work under Apache’s mod_gzip or Nginx’s gzip because, logically, it is gzipping the content, and to do that it must buffer content to gzip it. Any sort of web server gzipping would affect this. In short, at the server side, we need to disable gzip and … Read more

endl and flushing the buffer

Output is generally buffered before it’s written to the intended device. That way, when writing to slow to access devices(like files), it doesn’t have to access the device after every single character. Flushing means emptying the buffer and actually writing it to the device.

PHP buffer ob_flush() vs. flush()

ob_flush sends an application-initiated buffer. There may be multiple nested ob_start()‘s in any PHP script. ob_flush passes the current content to the upper layer. PHP itself might (at its own discretion) buffer output. This depends on the back-end. But usually FastCGI has a socket buffer on its own. Therefore flush() needs to be invoked as … Read more