I have a JavaScript application that can allow a user to fire off multiple, overlapping read-only requests to my Tomcat server, such that later requests should cancel and override any earlier requests. I could disable all my client side controls until the request comes in, but I would rather keep them enabled and let the user click whenever they want, and cancel previous requests.
What I would like to do, is cancel all but the latest request, so that my server does not waste time completing requests that will never be seen. I want the server to abort the thread it is running for that request in order to reduce server resources.
What's the best way do this?