Is it possible to start a response before action is fully executed?

Hello Rails experts:

I have a Facebook application that is suffering from the 8-second timeout issue in Facebook. The problem is that facebook takes a long time to respond to my api calls and in the meanwhile, my application keeps waiting for it and times out. The user, as a result, sees the infamous "try again" button and error.

What I am wondering is this:

Is there a way to start sending a response to the http request (like, for example, just send the html and head tags, and maybe a short body showing just "loading" or something) and then execute the action (while the user waits in the browser), and then complete the response after the action is fully executed?

I think if this were possible, this would solve my Facebook timeout problem.

Your help is much appreciated. Regards,

- Anand

Developer of