Now I met with a problem with using long polling, my situation is:
- The client will send ajax request to server for latest application
data, the data is required to update web page.
- We don’t know when the data will change, so we can either choose to ask server periodically( traditional http polling ) or long
polling. I used long polling to save resources.
- If an user visit the page, the request is sent to server immediately. And on the server side, it is hold until an event
happen, then the data is returned.
- I am using java servlets on server side.
The problem is:
Suppose if a request from client A is under processing. There are two bad cases:
The client refresh the page, then a new ajax request will be sent to the server. The the server might need to process many useless duplicate requests
Then the client closed the page because of some
reasons. How should I know the client has left and how to deal with
How can I deal with these cases, the prevention is on the client side or server side.