I have a centOS 8 server with Apache FPM/FastCGI as webserver.
I want the output to be seen right after each echo.
I tried setting output_buffering = Off
in php.ini
and used below code:
ob_implicit_flush();
ob_start();
echo '1';
ob_end_flush();
@ob_flush();
flush();
sleep(5);
echo '2';
but page remains on loading for 5 seconds and outputs 12 instead of outputting 1 then 2 after 5 seconds.
I used fastcgi_finish_request()
to output the whole buffer and do stuff in background and it works correctly.
And also, gzip and deflate are both turned off.
I use above code on my local Windows machine with Apache and also on another server with LiteSpeed and they work without a problem.
Your help is much appreciated!