I have a comet-driven chat script in my site
My Servers configuration is NGINX with PHP-FPM , I also have apache installed on different port.
When I try to run the chat script on Apache and I do flood the buffer ( my output buffering size is 1 KB) when I flood it with 1024 character, it flushes automatically That's in apache.
But in nginx it doesn't.
My code is very similar to this
<?php
// this is to fill the buffer and start output; and it works on apache normally
echo str_repeat(" ",1024);
while($condition){
// Some code here...
$messages = getMessagesFromDatabase();
if($messages){
echo "output"; // output works on apache but not nginx
flush();
ob_flush();
}
usleep(500000); // 0.5 Second
}
?>
in my nginx configuration i turned gzip off, proxy_buffering off,
is there a way to avoid buffering in nginx, I searched a lot here in stackoverflow but I couldn't reach to a solution
and please notice: I don't want to turn off buffering in all of my php configuration I just want this to happen in the chat script
Upgrade your nginx server {} config: