In my app I have a map and when the user does any operation on the map a request is sent to the server asking it to give it the map for the new bounding box but the problem now is that if a user say zooms in fast or pans the map continuously we end up sending many requests to the server and end up sending back the result to the client too.
Now I want to handle this more gracefully both at the server end and at the client end. I have thought of ways to handle the same at the client end but I need a way to do the same at the server end gracefully. what i mean is I dont want to end up processing stale requests which my client doesnt expect a response frm anyways. IS there a way I can achieve the same.
I am using MVC architecture in .NET Framework.
Thanks in advance.
P.S.All these queries are obviously ajax queries
Multiple ways to do this :
First way :
On the server side where you receive the request from client for new bounding window information, have the server operation wait for a small fraction of time ( the duration of time can be fine tuned later ) before it starts the processing.If there is a new request arriving from same client ( for the same zoom operation ) within this wait time , then let the old request be discarded. When no new request arrives from the client after the wait elapses , the server interprets the current request as the final one and processes this one. In order to minimize the delay appearing on the client side , the server can prepare those resources necessary to process the request which do not depend upon the exact details of the zoom parameters.
Second way ( can be used along with the first approach ) :
If the server is capable of it , use multiple threads for processing client requests. This way , you can safely discard the stale results and still avoid any delay in zooming appearing on to the client.