Server-Sent Events
Subject: Computer and Technology noun /ˈsɜːr.vər ˌsɛnt ɪˈvɛnts/ 1 definition
- web-development
- computer-networking
- real-time-communication
- web-apis
-
Definition (noun)
Entry #173 · UpdatedServer-Sent Events (SSE) is a standardized web technology that allows a server to push asynchronous, UTF-8 text messages to a client over a single, long-lived HTTP connection formatted with the
text/event-streammedia type. In browsers, applications subscribe to the stream using the nativeEventSourceAPI, which automatically parses incoming frames, handles reconnect delays, and resumes missed events viaLast-Event-IDheaders. Unlike full-duplex WebSockets or repeated HTTP polling, SSE is strictly unidirectional from server to client over standard HTTP, making it lightweight and firewall-friendly whenever only downstream updates are needed.Common Forms
Standard EventSource Streams: Browser-managed
GETsubscriptions built on theEventSourceinterface, providing native frame parsing, server-controlledretry:intervals, and automatic reconnection without third-party libraries.Fetch-Based POST Streams: Custom streaming consumers built on
fetch()andReadableStreamthat parsetext/event-streamresponses when request bodies or custom authorization headers are required, such as streaming LLM completions.Named Event Streams: Streams that pair
data:payloads with customevent:fields so a single connection can multiplex distinct update types and route them to dedicated client listeners.HTTP/2-Multiplexed Streams: SSE endpoints served over HTTP/2 or HTTP/3 multiplexing, allowing multiple concurrent streams to share one underlying transport connection and avoid HTTP/1.1's six-connection-per-origin browser limit.
Example
During a production rollout, a CI/CD dashboard opens an
EventSourceconnection to/deployments/842/logs, receivingContent-Type: text/event-streamframes containingid: 19anddata: {"step":"migrate","status":"ok"}as each build stage finishes. When the user's connection drops momentarily, the browser automatically reconnects and sends aLast-Event-ID: 19header so the server resumes streaming from the next log entry without duplicating earlier output.