4 ms·
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 "re
by luchs 10y ago
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.
- est 10y agoServer-Sent Event (SSE) is very underrated HTML5 technology. If you dont need bi-directional realtime messaging, use SSE.
- bradgessler 10y agoThe only big barrier to adopting the EventSource API is the complete lack of support from Microsoft's browsers: http://caniuse.com/#feat=eventsource http://caniuse.com/#feat=eventsource
- lobster_johnson 10y agoFortunately, polyfilling is fairly easy, e.g. https://github.com/Yaffle/EventSource https://github.com/Yaffle/EventSource.