Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Did you look into the EventSource API? It's basically automatic long-polling with a simple file format built into the browser. It supports pretty much every "real-time" pattern: regular polling, long polling, and streaming.

The browser handles the log position for you (via the id field and the Last-Event-ID header) and automatically reconnects when the server closes the stream or the connection is lost.

The proposed Redis API seems to fit extremely well to this model. My previous usage of EventSource with Redis worked by sending the entire state whenever someone (re-)connects and using PubSub afterwards. This works well for me, but likely doesn't scale very well.



Server-Sent Event (SSE) is very underrated HTML5 technology.

If you dont need bi-directional realtime messaging, use SSE.


The only big barrier to adopting the EventSource API is the complete lack of support from Microsoft's browsers: http://caniuse.com/#feat=eventsource


Fortunately, polyfilling is fairly easy, e.g. https://github.com/Yaffle/EventSource.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: