I need to flush the content before the page loads, but I can't add additional characters because what I need to print is a JSON encoded array. I have PHP 7.2 and nginx.
I read this and I tried almost all answers but my script only flushes if I reach the minimum size. I configured my php.ini
and nginx.conf
as the marked as working question says.
What I mean if that if I use the following code, it works.
ob_implicit_flush(1);
for($i=0; $i<10; $i++){
echo $i;
echo str_repeat(' ', 1024*64); #This is to reach the minimum buffer size in order to flush
sleep(1);
}
But if I remove the str_repeat
and I just print a JSON encoded array that doesn't reach the minimum size to flush the data I still need to wait for the page to load.
I need to be able to flush whenever I want, without that limit.