I know this topic has been covered many times, but none of the solutions on SO seem to work for PHP 7.x (for example, everthing in close a connection early will not work. The same goes for all similar answers on similar questions).
I want to close the connection of a php script early, so the browser does not stall on longer running tasks. I have a PHP 5.x server setup where this works wonderfully since years. But I struggle to make it work on a PHP 7.x setup.
I can not use fastcgi_finish_request() as I am not running PHP with FastCGI. Also, any command line oriented solutions (exec etc.) are not an option. Also, threads are not an option because pthread is not installed on the server.
After long testing, I found out that for PHP 5.x to achieve proper closing of the connection while still continuing with the script needs different "recipes" depending on server configuration. Where for some servers this does the trick
header("Content-Length: 0");
ob_end_clean();
ob_end_flush();
echo(' ');
other configurations will only need this to achieve the same:
header("Content-Encoding: none");
header("Content-Length: 0");
flush();
With PHP 7.x, though, I have failed to come up with the right "recipe".
Anybody out there that had more luck or can suggest a different solution?