I’m trying to do the following in PHP…
[php]<?php ob_start(); echo "We'll email you as soon as this is done."; // get the size of the output $size = ob_get_length(); // send headers to tell the browser to close the connection header("Content-Length: ".$size); header('Connection: close'); // Flush the buffer ob_end_flush(); flush(); // do some logging work etc. sleep(5); exit; ?>
…but it doesn’t work. The “Connection: close” header is removed. There is a “Content-Length” header, but perhaps this is being ignored and replaced by Apache anyway.
Has anyone else been able to solve this?
My PHP mode is 5.3 FastCGI. Extra web security is enabled.[hr]
Sorry, just to clarify: I expect the page to appear quickly. Instead, it waits the full 5 seconds for sleep(5) to complete, before the page starts rendering.
I want to be able to let the client render the page, and keep the PHP going to do some logging etc.