Search code examples
phpcodeigniteriisfastcgibackground-process

php close connection and continue on background


How can i close the connection and continue on background on the following environment ?

SERVER : Microsoft-IIS/7.0

PHP support : (run as FastCGI application)

PHP version : 5.2.17

Host : Shared , CRON : NO

I tried many existing solutions , it works on Local wamp server or in a PHP LINUX server but not in IIS.

// buffer all upcoming output
ob_start();
echo "Here's my awesome web page";

// get the size of the output
$size = ob_get_length();

// send headers to tell the browser to close the connection
header("Content-Length: $size");
header('Connection: close');

// flush all output
@ob_end_flush();
@ob_flush();
@flush();

// close current session
if (session_id()) session_write_close();

sleep(10);

// DO SOME BACKGROUND WORK ...

Please help.

Thanks


Solution

  • Call this: fastcgi_finish_request();

    See also: