PHP: How to display page before the script is over?
<p>My script consists of two parts.
The first part generates HTML page.
The second part loads a resourse from the net and saves it into a file.
Loading is a long operation and can take up to 10 seconds.
The first and the second parts are completely indepenent (loading has no impact on the look of the page).</p>

<p>At the end of the first part I call flush(), that makes page displayed instantly.</p>

<p>However, embedded SWF movie is not displayed at this moment.</p>

<p>SWF is the key element of the page and it must be displayed as fast as possible.
It is embedded in the page with SwfObject library.
And the problem is that SwfObject starts to open SWF on "onLoad" event of the page.</p>

<p>But "onLoad" event comes at the end of the <em>second</em> part.
That is "onLoad" can occure in 10 seconds.
So in spite flush() call the user has to wait for 10 seconds in vain.</p>

<p>Is it possible to solve the task on PHP side?
Is it possible to run "loading" task (the second part) in a separate process?
Is it possible to tell the browser before the second part starts, that the page is reay and you can broadcast the "onLoad" event.</p>

<p>Thanks for reading this very long story.</p>
