server-sent events

From IndieWeb
Jump to: navigation, search


server-sent events is a DOM API for receiving push notifications from a server via HTTP. Unlike websockets, they're designed for one-way communication between a Web server and a client (Web browser, another Web server or a client application).

Why

Server-sent events are one way to implement real-time comments display on your posts.

How

How does one implement server-sent events, especially in combination with a comment updating system?

(stub, to be filled in)

https://developer.mozilla.org/en-US/docs/Server-sent_events/Using_server-sent_events

server side

One option is using the nginx-push-stream module for nginx. This is e.g. used on chat.indieweb.org.

IndieWeb Examples

indieweb.org

The IRC logs use server-sent events to push new IRC messages to the browser in real time.

aaronparecki.com

Aaron Parecki uses server-sent events to push new posts onto his home page in realtime.

Sweetroll

sweetroll uses server-sent events to show in realtime that the current page has been updated.

Issues

Not Supported in IE

While fairly widely supported, server-sent events are currently not supported in IE.

  • MDN lists some polyfill libraries that cover IE and older browsers.

See Also