I’m trying to reverse engineer how facebook handles their notifications, where when you get a message you get instantly notified via the browser.
I’ve fiddled with it for a little bit and realized that there is always a pending GET request “listening” if you will to some sort of update from the server. This appears to be some sort of observer pattern. I was just wondering if this pattern was documented somewhere.
The technique is actually called Long Polling. This is one of the popular Comet techniques to get around the limitations of traditional polling.
You may want to check out the following Stack Overflow post for a very simple example:
UPDATE:
In addition to the above, I suggest that you check out the accepted answer to the following Stack Overflow post for a detailed description of the technique: