Frank DENIS random thoughts.

Closing the users browser connection whilst keeping your php script running

Here is an old, but still relevant trick for PHP coders: Closing the users browser connection whilst keeping your php script running.

To summarize because the site seems to often be down:

<?php
 ob_end_clean();
 header("Connection: close");
 ignore_user_abort(); // optional
 ob_start();
 echo ('Text the user will see');
 $size = ob_get_length();
 header("Content-Length: $size");
 ob_end_flush(); // Strange behaviour, will not work
 flush();            // Unless both are called !
 // Do processing here 
 sleep(30);
 echo('Text user will never see');
?>