Browsers need ways to stream updates. Server-Sent Events (SSE) and WebSockets overlap but optimize for different shapes of traffic.

Server-Sent Events

  • One-way: server → client over a long-lived HTTP response.
  • Built on HTTP/1.1 or HTTP/2; works through many corporate proxies that block raw WebSockets.
  • Browser EventSource handles automatic reconnect with Last-Event-ID.
  • Best for notifications, progress streams, live logs, dashboards fed from the server.

WebSockets

  • Full-duplex after upgrade; low framing overhead for chat, games, collaborative editing.
  • Requires connection management, auth on each socket, and often sticky sessions or pub/sub backing.

When SSE is enough

If clients only receive updates and POST actions separately (REST), SSE reduces complexity.

When you need WebSockets

High-frequency bidirectional messaging or binary payloads not ideal for SSE text frames.

Operational tips

Disable buffering at reverse proxies for SSE (nginx X-Accel-Buffering: no). Always plan backoff and heartbeats so idle connections are not dropped silently.