Server-Sent Events (SSE) is a server push technology enabling a client to receive automatic updates from a server via an HTTP connection, and describes how servers can initiate data transmission towards clients once an initial client connection has been established. They are commonly used to send message updates or continuous data streams to a browser client and designed to enhance native, cross-browser streaming through a JavaScript API called EventSource, through which a client requests a particular URL in order to receive an event stream. The EventSource API is standardized as part of HTML Living Standard[1] by the WHATWG. The media type for SSE is text/event-stream.
All modern browsers support server-sent events: Firefox 6+, Google Chrome 6+, Opera 11.5+, Safari 5+, Microsoft Edge 79+, Brave.[2] Since SSE does not use either persistent connections nor chunked transfer encoding, HTTP/1.1 is not a technical requirement.
History
The SSE mechanism was first specified by Ian Hickson as part of the “WHATWG Web Applications 1.0″ proposal starting in 2004.[3] In September 2006, the Opera web browser implemented the experimental technology in a feature called “Server-Sent Events”.[4][5]
The W3C published Server-Sent Events as a Recommendation on February 3, 2015, after years of development through Working Drafts and Candidate Recommendations.[6]
Example
var source = new EventSource('updates.cgi');
source.onmessage = function (event) {
alert(event.data);
};
Technology
When sending high-frequency data , the server must manage backpressure to prevent saturating clients.[7] This is mitigated in the following ways:
- Client-side buffering: Browsers have limited buffer space for incoming server-sent events[7]
- Adaptive rate limiting: Servers can adjust event frequency and monitor connection health
- Event batching: Combining multiple events into larger and less frequent transmissions
See also
References
- ^ “HTML Living Standard: 9.2 Server-sent events”. WHATWG. 31 March 2022.
- ^ When can I use… Server-sent DOM events
- ^ Hickson, Ian, ed. (1 January 2006). “Server-sent DOM events”. Web Applications 1.0. WHATWG. Retrieved 2024-05-09.
- ^ Bersvendsen, Arve (1 September 2006). “Event Streaming to Web Browsers”. dev.opera.com. Archived from the original on 2014-07-04.
- ^ Stream Updates with Server-Sent Events, Eric Bidelman, HTML5Rocks website.
- ^ “Server-Sent Events publication history”. W3C. 2021-01-28. Retrieved 2026-04-14.
- ^ a b Mohamed-Ali (2025-03-11). “Server-Sent Events: A Comprehensive Guide”. Medium. Archived from the original on 2025-06-24. Retrieved 2026-04-14.
External links
- Server-Sent Events. HTML Living Standard.
- HTML5 Server-push Technologies, Part 1. Introduction into HTML5 Server-push Technologies. Part 1 covers ServerSent Events.
- Using Server-Sent Events. A concise example of how to use server-sent events, on the Mozilla Developer Network.
- EventSource reference on MDN
- Django push: Using Server-Sent Events and WebSocket with Django Django push: Using Server-Sent Events and WebSocket with Django.
- Server-Sent Events vs WebSockets