Server-sent events, WebSockets, and HTTP
In case people don&#x27;t know, Mark Nottingham (the author) is the chair of the HTTP working group at the IETF. He isn&#x27;t just some guy with opinions on the internet. (Sorry mnot!)<p>I&#x27;ve never found pub&#x2F;sub quite the right abstraction, because almost every implementation I&#x27;ve seen has race conditions or issues on reconnect. Usually its possible to lose messages during reconnection, and there&#x27;s often other issues too. I usually want an event queue abstraction, not pub&#x2F;sub.<p>I met mnot a few years ago when we (the braid group) took a stab at writing a spec for HTTP based streaming updates[1]. Our proposal is to do state syncronization around a shared objects (the URL). Each event on the channel is (explicitly or implicitly) an update for some resource. So:<p>- The document (resource) has a version header (ETag?).<p>- Each event sent on the stream is a patch which changes the version from X to Y. Patches can either be incremental (&quot;insert A at position 5&quot;) or if its small, just contain a new copy of the document.<p>- You can reconnect at any time, and specify a known version of the document. The server can bring you up to date by sending the patches you missed. If the server doesn&#x27;t store historical changes, it should be able to just send you a fresh copy of the document. After that, the subscription should drip feed events as they come in.<p>One nice thing about this is that CDNs can do highly efficient fan-out of changes. A cache could also use braid to subscribe to resources which change a lot on the origin server, in order to keep the cached values hot.<p>[1] <a href="https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;html&#x2F;draft-toomim-httpbis-braid-http-02" rel="nofollow">https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;html&#x2F;draft-toomim-httpbis-b...</a><p>We&#x27;ve done some revisions since then but have been working on getting more running code before pushing forward more with the approach. Most recent draft &amp; issues: <a href="https:&#x2F;&#x2F;github.com&#x2F;braid-org&#x2F;braid-spec&#x2F;blob&#x2F;master&#x2F;draft-toomim-httpbis-braid-http-03.txt" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;braid-org&#x2F;braid-spec&#x2F;blob&#x2F;master&#x2F;draft-to...</a>