Tuesday, June 5, 2007

Reverse Ajax

A couple of months back, i had posted simple AJAX tutorials on how to initiate simple AJAX calls and get the response from the server. Today I stumbled upon an article on reverse AJAX, click here to view the original post.

Reverse AJAX is actually an implementation (seems more of a marketing buzz word to me) rather than a technology. In case of AJAX it is the browser that initiates the request, but what if the server needs to inform the browser of something ?

Suppose there are 6 clients (browsers) connected to a server viewing the same financial record, if one of the clients updates the record then how do the other connected clients get informed that the record has been updated ? this is a typical problem that a reverse AJAX solution can be used to target.

There are generally 3 methods that can be used for implementation of Reverse AJAX, the details can be read on the original link that I posted earlier

1) COMET or SLOW LOAD
  • COMET was coined by Alex Russell , its a technique to keep keep alive HTTP connections
  • Bryce Nesbitt's example on slow loading, it uses an frames to keep the connection open
2) Polling
  • the browser polls the server after some specified intervals to check if something new has happened
3) PiggyBack
  • piggy backing means that whenever a browser requests an operation, you send back the notification with the result of that request, hence piggy backing on the response
I have not used any of the above mentioned techniques but in my opinion a small framework can be built that sends an asynchronous call to the server and listens for the response, the server would only resonse if some event has occured. This would be similar to slow load technique but at least you wont have to use frames with it

I'll try it out if I can get the time, I'm currently preparing for an MCTS exam due in July... so lets see

No comments: