Add a GUID to AJAX Requests to Allow De-Duping on Server
Currently, it is possible for an AJAX request to be send multiple times by the browser and handled as many times by the server. Consider the following scenario:
You see where this is going.
In Novell Vibe, we solved this problem by adding an ID to our AJAX requests that were susceptible to this issue. Then, when the server receives the request, it checks to see if it's already processed that id. Unfortunately, we've only been able to do this on a case-by-case basis, and it's not trivial code when done at the application layer. This could be handled much more elegantly by Lift itself as part of the generalized AJAX dispatch mechanism.
- Browser initiates an AJAX request
- Server receives request, processes and returns response
- Browser still hasn't received response (due to network latency), and assumes request has timed out
- The request goes back into the local AJAX queue and is sent again
- Server receives request a second time, processes and returns response
You see where this is going.
In Novell Vibe, we solved this problem by adding an ID to our AJAX requests that were susceptible to this issue. Then, when the server receives the request, it checks to see if it's already processed that id. Unfortunately, we've only been able to do this on a case-by-case basis, and it's not trivial code when done at the application layer. This could be handled much more elegantly by Lift itself as part of the generalized AJAX dispatch mechanism.
Leave a comment