tags : HTTP, Web Development, WebSockets, WebRTC

FAQ

  • AJAX + XMLHTTPRequest (Also can use JSON) : no longer popularly used
  • FetchAPI
  • WebSockets

Server-Sent Events (SSE)

  • Introduced 2004
  • SSEs are sent via the normal HTTP protocol
  • MIME type for SSE is text/event-stream
  • Server Push implementation enabling a client to receive automatic updates from a server via an HTTP connection
  • Usage
    • Send message updates/data streams to a browser client
    • Client uses JavaScript API EventSource, to recieve the event stream
    • Can run outside of browser context too

Extra details

  • HTTP/1.1: 6 SSE connections per browser per domain limit
  • HTTP/2: 100 SSE connections per browser per domain limit
  • NOT a direct replacement for WebSockets
    • SSE does not support messages back from the client to the server.
    • You can however do full duplex w SSE(S->C) and RESTAPI(C->S), but that’s a hack.
    • Usually SSE easier to setup than Websockets