Posted by Kelvin on 03 Feb 2014 at 12:15 am | Tagged as: PHP
Here's one way to send and close the connection to the client and for the PHP script to continue processing, presumably to perform some processing that is time-consuming:
'Text user will see'"Content-Length: $size"// Strange behaviour, will not work
// Unless both are called !
//do processing here
'Text user will never see');
//do some processing
Note that some stackoverflow answers which mention the use of ignore_user_abort are mistaken. That's not required at all. And you'll need the Content-Encoding: none header, otherwise it won't work properly with clients that accept gzip encoding for example.