Queuing mechanism for server-side AJAX requests

I am struggling with a situation on a site where click users generate AJAX requests, for example. with some visual effect when the answer comes. Sometimes it happens that the user does not wait until the request is completed (although he sees the download indicator) and starts clicking on other elements, such as crazy ones. Because, in principle, I cannot and do not want to disable this feature, I tried (more or less successfully) to make sure that at any time when a new request is launched, the previous one is interrupted (on the client side) and its handlers are no longer called - any The request comes with the latest victories.

Although somewhat successful on the client side, now I am wondering if there is a way to simulate this behavior on the server. Since I cannot really kill the previous request, disconnect from it, it will still work to the end and will consume valuable resources. If the user clicks on 20 elements, he will see only the result of the most recent request, but there will still be 20 requests on the server that spend the processor on unnecessary work.

Is there a way to implement the last-win strategy for multiple requests of the same resource in ASP.NET/IIS? I suppose that requests in any case fall into the queue inside, and I need it for IIS when it tries to delete the next queue, just see if there are others and only serve the last of the same session.

+5
source share
1 answer

I know that in ASP on IIS you can check for isClientConnected and abort if the client disconnects.

I believe something like this will exist on most platforms.

But I do not know how this works with ajax?

+1
source

All Articles