我在这个问题上花了几个小时,我附带了一个在Apache和Nginx上工作的函数:/**
* respondOK.
*/protected function respondOK(){
// check if fastcgi_finish_request is callable
if (is_callable('fastcgi_finish_request')) {
/*
* This works in Nginx but the next approach not
*/
session_write_close();
fastcgi_finish_request();
return;
}
ignore_user_abort(true);
ob_start();
$serverProtocole = filter_input(INPUT_SERVER, 'SERVER_PROTOCOL', FILTER_SANITIZE_STRING);
header($serverProtocole.' 200 OK');
header('Content-Encoding: none');
header('Content-Length: '.ob_get_length());
header('Connection: close');
ob_end_flush();
ob_flush();
flush();}
您可以在长时间处理之前调用此函数。
本文介绍了一个用于Apache和Nginx服务器的功能函数,该函数能够帮助开发者在执行长时间的任务前优化服务器资源分配,确保任务顺利执行。
3194

被折叠的 条评论
为什么被折叠?



