I’m using nginx with PHP-FPM (APC is installed).
I need PHP’s flush()
to work. Is this possible?
Things I’ve tried so far:
- Disabling all output buffering in
php.ini
, as well as output compression. - Disabling
gzip
in nginx’s configuration. - Setting nginx’s
fastcgi_*
buffering settings andfastcgi_max_temp_file_size
to zero.
I’m sure I must be missing something, since I’ve run across many posts here and elsewhere where people claimed they’ve got it working, but I’m having no luck, it would seem.
Sadly it's not possible with nginx. The nginx implementation of fastcgi requires a buffer to be in place, even if you set the buffering directive to 0 it will just cause it to buffer to disk instead of memory.
You'll have to figure out some alternative system such as a queue where you can poll for the status. (think ala gearman for instance)
Edit: This is since possible: http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_buffering
I wanted the same thing, and it turns out it is possible. All you need is this before anything is echo'ed:
Then to flush you do the flush as normal:
Nginx seems to pick up on the encoding having been turned off and doesn't gzip.
It's possible. Put this in the server section of your site's config file:
Put this in php.ini
Be careful. Disabling these buffers can have severe performance implications.
It IS possible, look at this answer.
I tried it myself and it works.
Upgrade your nginx server {} config: