php不同运行模式(sapi)下清空内存缓冲池提前返回结果的实现
if (PHP_SAPI == 'cgi-fcgi') { echo $response; fastcgi_finish_request(); } elseif (PHP_SAPI == 'apache2handler') { header("Connection: close\r\n"); header('Content-Encoding: none\r\n'); echo $response; $size = ob_get_length(); header("Content-Length: " . $size . "\r\n"); // send info immediately and close connection ob_end_flush(); flush(); ob_flush(); }