The general approach from this article by merlyn can be applied here i think (from this thread: CGI::Application timeout). Basically your building needs to be forked off, and then your "Please wait" screen refreshes to a handler that checks if the process is done, and goes there when it is done. It can also check progress (maybe check filesize or whatever depending on what the build does).
Comment on Re: Mason: Please Wait While Generating
Mind you that N refreshes to your app can happen from this and those N runs can make the generation that much slower than just waiting for the page to be generated. What is taking so long to generate the page in the first place? Is the server underpowered?
Mind you that N refreshes to your app can happen from this and those N runs can make the generation that much slower than just waiting for the page to be generated.
If a simple probe to tell if it's ready or not makes your app go "much slower", then you haven't quite designed it right. Gotta keep the probe cheap.