I am optimizing a few of the PHP scripts by:
- doing all that generates output to browser
- closing connection to browser
- doing some more processing
The processing bit cannot be avoided, but the speed of execution (from
visitors’ point of view) is awesome this way. The problem is that we
have tried migrating the script to NginX + FastCGI (it works on Apache +
mod_php) but it doesn’t close the connection anymore, it keeps it open
until the end… Which makes scripts slow again.
I am using Content-Length to allow server to figure out that all content
was already generated. This is the test case:
The browser shows this page immediately in Apache+mod_php but it waits
for 10 seconds in NginX + FastCGI.
I am a bit stuck here and would appreciate some help… Is this a
problem with FastCGI? Is there another way to do it?
Posted at Nginx Forum: