Server-Sent Events as an Alternative to Long-Polling and Websockets

“Server-Sent Events” (SSE) is the estranged cousin of AJAX and Websockets.

It differs from AJAX in that you hold a connection open while you can receive intermittent messages. It differs from Websockets in that it’s still HTTP based, but only receives messages (you still have the HTTP overhead, but don’t have to support full-duplex communication).

It bears a closer resemblance to Websockets because it holds a connection, and you receive similar messages with identical events (“open”, “error”, “message”). The server, on the other hand, sends plain-text communication (as opposed to Websocket’s new support of plain-text -and- binary communication) in messages that resemble the following:

data: hello world

or (identically):

data: hello 
data: world

This guy wrote a great tutorial: