News for hackers. Stuff that matters.
Re:Server-Sent Events: The simplest realtime browser spec by pornel on Friday April 04, 2014 @09:28PM (#7535597)
On the HTTP level it's quite similar to slow-loading iframes (although with less overhead on the wire), but the interface and usability are better.

The browser will try hard to keep the connection always on for you (unless instructed otherwise). You don't have to implement your own logic for offline/online detection, exponential backoff, etc. Thanks to id:/Last-Event-Id header the server can make error recovery transparent to the client.

You do need node/tornado/etc to take full advantage of it, but if all you have is PHP or such, then you can still make it real-time-ish. Because SSE automatically reconnects you can have any behavior ranging from a single persistent TCP/IP connection, through Comet, to regular polling. You control this with the `retry:` line and by (not) closing connection on the server (e.g. keep persistent connection when load on the server is low, set high `retry:` and close the connection when the load is high).

There are no comments on this comment yet.