In my application, the client can request a complex task that could take 1-2 minute to complete. The task runs in a separated thread and the request handler communicates with it via a BlockingQueue.
Currently, the sever immediately redirects the client to a waiting page which polls the server every 10 seconds. However, this is quite inefficient and the client may have to wait for an extra 10s if the task finished right after a poll.
What I would like to do is to allow the request handler (for the waiting page) to be blocked until the task is done and only then write the response to the user. Based on my observations, most browsers will use a longer timeout if the server accepted the TCP socket (and maybe has written back some header??), but I am not sure about the exact timeout across different browsers.
Is it realistic to make the browser wait for 2 minutes? Does anyone has any experience on this or better ideas?