posted 15 years ago
Well, reverse AJAX is in fact information sent from the server to client asynchronously, meaning the client didn't directly request the information. In other words, it's a form of push technology.
Now, as for how it works, that's a bit more complicated. There's basically three ways to pull reverse AJAX off.
First is polling. This is simple the client periodically making an AJAX request asking if there's anything the server needs to send. If you're saying "that's not really push", you're right! It's a bit of a cheat. But, all of reverse AJAX is because the the underlying nature of HTTP. The important thing is that to the user, it looks like push.
Another approach is piggybacking. This is where the client makes a request, and the server attaches some information to the response above and beyond what the client requested. Assuming the client knows how to handle that, it works. This is nice because there's no extra load on the client or server (polling there's a periodic request pinging away), but it has the disadvantage that there's no guarantee when the information to be pushed is actually pushed.
The last technique has a couple of names, but most commonly it's called COMET. It's also known as long-lived requests. This is also by far the most complex method to implement. Basically, a request is made by the client, and the server *very* slowly responds, which causes the connection to be maintained. Periodically, when the server has something to push, it'll "burst" send the information, so to speak. This approach gives you real-time push, which is great. But, it has a serious down-side: holding connections open like that isn't how the underlying protocols are meant to work, and most servers aren't terribly happy about it. If your traffic gets too great, you'll chew up threads on the server and wind up bringing your site down.
Most good implementations will periodically break that long connection and start a new one (DWR does this), and that alleviates matters a little. But it's still not great.
There are however some servers, open-source projects and commercial, that are specially designed to deal with COMET. They aren't yet widespread, but they're growing in popularity.
-- <br />Frank W. Zammetti<br />Founder and Chief Software Architect<br />Omnytex Technologies<br /><a href="http://www.omnytex.com" target="_blank" rel="nofollow">http://www.omnytex.com</a><br />AIM/Yahoo: fzammetti<br />MSN: fzammetti@hotmail.com<br />Author of "Practical Ajax Projects With Java Technology"<br /> (2006, Apress, ISBN 1-59059-695-1)<br />and "JavaScript, DOM Scripting and Ajax Projects"<br /> (2007, Apress, ISBN 1-59059-816-4)<br />Java Web Parts - <a href="http://javawebparts.sourceforge.net" target="_blank" rel="nofollow">http://javawebparts.sourceforge.net</a><br /> Supplying the wheel, so you don't have to reinvent it!