One of the biggest problems I see with the web today is the ability to stream data. In the early years it was all done by polling which results in slower data retrieval and constant up and down connections which are expensive. Then, flash and java-based applets came to the scene and provided raw TCP/IP connections. However, that solution required plugins, which are also frowned upon. New strategies emerged referred to as long-lasting HTTP connections that did not require plugins. Essentially, the HTTP session would stay open until the server had data to provide it and then would respond. This, in a sense, provided live streaming data, but at the cost of opening and tearing down connections. For example, if a single message was destined for every connected client, they would all disconnect and re-connect at the same time causing massive connections to the server. Last but not least, websockets were introduced. Websockets allowed an HTTP session to be upgraded to a bidirectional streamed session that would never close and allow messages to be sent back and forth during the duration of the session. However, that session would close once the user left the page. As a result, companies wanting to employ standards based bi-directional streamed technologies via WebSockets had to typically employ one of the following systems:
- Use AJAX to turn every link into an AJAX link so that the content just got refreshed without navigating away from the page. This results in complicated backend javascript, difficult bookmarkability control, etc.
- Use frames so that part of the page was in a frame that never changed while the content was a separate frame. This results in no bookmarkability since the URL of the frameset never changes.
- Just deal with the up and down connections and use routers or other backend hardward to better manage the connections.
As a result, we still have no efficient way to manage bi-directional systems. Even using flash or java does not help as you have to tear down and re-establish the connection with each page view. Below is my request to establish such a technology.
First, I would continue to use the WebSockets technology as I think it has its place. I would just add support on the browser side to keep the connection alive across requests. In order to do this, each page would need to request the same base URL. If the browser notices that the base URL is the same and an existing connection to the URL exists, it would just re-join the connection. If not, it would first establish it. There would be an API to join the connection as well as a different API to always establish a new connection (in case pages wanted a new connection different from an existing one). The browser would need to establish some type of timeout so that if javascript did not invoke a request to re-join a connection once the page loaded, then it would kill the previous connection. Otherwise, connections would be left open and resources leaked in the browser. Further, the browser would require an XML file on the server for security reasons. This would be similar to a crossdomain.xml file but would tell the browser which hosts are allowed to keep a connection alive. When a link is clicked and navigated to, the browser would check if the host matches a host in the XML file. If so, it would keep that connection open until the next page requested to join the connection. There is obviously much more to this that would need to be thought out, protected against, etc. But I believe it is a start to something that would create more dynamic apps.
The best part of this request is that it is based on open standards per WebSockets and only requires browser interaction (not new servlet strategies or other strategies on the server-side). This request would greatly simplify a lot of existing code out there.
Let me know what you think. If we can get some backing around this idea, hopefully browser vendors will take off with it and get the WHATWG or W3C to investigate.
Thanks,
Nick