Lets say an operation could take 2 to 10 minutes on the server to perform, for example to update an index which is time consuming.
Would you perform the operation while holding the request? ie not sending a HTTP Response until the operation has finished? And if the client/browser drops the request, just continue with the operation anyway?
What is the alternative? To kick-off the operation, and response with “long-time operation kicked off” ? What if the operation fails mid-way how would the client know? Maintain a server-side “status” of the operation?
Thanks
You might also use a chunked response. First, push a chunk with some code that would display the “please wait” screen, flush the response and start the work. Then you can either push and flush chunks with periodical progress updates or just push one at the end with a “completed” information. Obviously you can employ JavaScript to get a nice UI.
(The above does not apply if you’re using WSGI as the first WSGI specification is written in a way that blocks using responses of unknown length so using chunked responses there is impossible.)