I have a php script that uses ImageMagick to process an image. What I’d
like to do is to flush the buffers just before the script calls
ImageMagick, that way the user at least gets some output in their
browser instead of getting an empty page until ImageMagick has done its
stuff (which takes a while).
At the moment I’m using a test page to simulate the above situation:<?php ini_set('zlib.output_compression', 0); echo str_repeat("hello\n", 800); flush(); sleep(5); ?>
However, I don’t receive the output in the browser until the full page
has been processed.
I’m using nginx/0.7.64 proxying to nginx/0.7.59 with spawn-fcgi to start
the php processes.
The front end nginx has proxy_buffering off;
I’m guessing this is something to do with fastcgi and the fastcgi buffer
settings in nginx, however I tried setting them to what seems to be the
minimum, but still don’t get the output in the browser (FF3.5) until the
php script is completely finished.
fastcgi_buffers 2 1k;
So how could I send the output to the browser when flush() is called in
the php script?
Posted at Nginx Forum: