Thursday, February 20, 2014

Pushing Data to Browser

Pushing Data to Browser

By Will Fox on Feb. 20, 2014

I noticed in one of the classes I take that uses as a discussion tool that changes to the page content was pushed real time without refreshing the page. This intrigued me immensely so I did some search and here is what I found out:

It's called "Push Technology", where data is pushed by the server to the browser instead of the browser pulling data from the server.

From Stackoverflow:

Q: Is there some way to PUSH data from web server to browser? Of course I am aware of Ajax, but the problem with Ajax is that the browser should poll the server frequently to find whether there is new data. This increases server load.Is there any better method (even using Ajax) other than polling the server frequently?
A1: Yes, what you're looking for is COMET Other good Google terms to search for are AJAX-push and reverse-ajax.
A2: Yes, its called Reverse Ajax or Comet. Comet is basically an umbrella term for different ways of opening long-lived HTTP requests in order to push data in real-time to a web browser. I'd recommendStreamHub Push Server, they have some cool demos and its much easier to get started with than any of the other servers. Check out the Getting Started with Comet and StreamHub Tutorial for a quick intro. You can use the Community Edition which is available to download free but limited to 20 concurrent users. The commercial version is well worth it for the support alone plus you get SSL and Desktop .NET & Java client adapters. Help is available via the Google Group, there's a good bunch of tutorials on the net and there's a GWT Comet adapter too.

A couple of frameworks that implement server pushing:

  • Direct Web Remoting (DWR): a Java lib that enables Java on the server and JavaScript in a browser to interact and call each other as simply as possible
  • Ajax Push Engine (APE): an opensource project that features a Comet server that implements the POST and GET methods of the HTTP protocol used only for AJAX Push. It also comes with a JavaScript Framework (JSF) that receives information sent by the server, handles the data, and sends back the users commands.