For days I have been experimenting with long polling/comet implementation for my site. I got the basic idea of how it works, this is where i run some tests.
On the other hand, I have been observing(firebug) how gmail and facebook implement long polling. What I noticed with gmail is that the ajax request does not continuously follow right after the current request expires, but it waits for several seconds/minutes before it fires the next one.
I played with it some more. I tried to login with gmail account A in firefox and gmail account B in chrome. I waited when the current ajax poll finishes and then I sent an email from account B to A. I was expecting that account A won't receive it until the next poll, but to my surprise Account A directly received it right after I hit the submit button.
How does gmail do this with long polling ?
If you try to visit my site and click on the Run button and open firebug, you can see that ajax spinner is always running. when the server responds with data, it requests the server again.
I think your assumption that Gmail uses (only) long polling is incorrect. According to this question (and the answer) it uses forever frame, and forever XHR. See also BrowserChannel, which they use for Gmail Chat.
Take a look at WebSync from Frozenmountain or SignalIR which take the work out of the backed pieces. I can vouch for websync as I use it everyday, but been hearing good things about signalir.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With