Web Protocols

What is Server-Sent Events?

Also known as: SSE

Definition

Server-Sent Events (SSE) is a standard that allows a server to push real-time updates to a web client over a single, long-lived HTTP connection using a simple text stream.

Server-Sent Events (SSE) is a W3C standard and HTML5 API that enables servers to push streaming data to a web browser over HTTP. Unlike WebSocket, which provides full-duplex communication, SSE is strictly unidirectional: the server sends events to the client, and the client cannot send data back over the same connection. The client initiates the stream by requesting a URL with a standard HTTP GET and an Accept header of text/event-stream. The server then holds the response open and writes UTF-8 text payloads formatted according to the SSE specification (originally defined in the HTML5 spec, later refined in the W3C specification). Each message consists of one or more lines starting with field names such as "event:", "data:", "id:", and "retry:", separated by double newlines.

The protocol relies on basic HTTP mechanics, not a separate upgrade handshake. This makes SSE trivial to implement on any HTTP server (Apache, Nginx, Node.js, Python, etc.) and allows it to traverse standard HTTP proxies and firewalls without special configuration. The EventSource interface in the browser automatically handles reconnection: if the connection drops, the browser reconnects and sends the Last-Event-ID header, allowing the server to resume from where it left off. IETF RFC 7931 provides a more formal specification for the wire format. SSE removes the overhead of polling and is far simpler to deploy than WebSocket for use cases where the server is the only sender, such as live news feeds, stock tickers, status dashboards, or notifications.

In the wider stack, SSE competes with and complements WebSocket and long-polling. It is less complex and has better native browser support for one-way streams than WebSocket (which uses a different binary framing and requires a special upgrade). However, SSE is limited by browser maximum concurrent connections per domain (typically 6, though HTTP/2 alleviates this) and by the inability to send binary data without encoding. For applications needing bidirectional streaming, WebSocket remains the correct choice. SSE excels where simplicity, reliability, and standard HTTP infrastructure matter more than low latency in the upstream direction.

Key facts

  • SSE uses standard HTTP/1.1 with no upgrade handshake, just a long-lived response.
  • Browser support via the EventSource API; reconnects automatically with Last-Event-ID.
  • Text-only stream; binary data must be Base64 or similar encoded.
  • Limited to about 6 simultaneous connections per domain under HTTP/1.1.
  • Defined in W3C specification and IETF RFC 7931.

How it works in practice

A weather dashboard subscribes to an SSE endpoint at /events/weather. The server pushes a JSON payload containing temperature and wind speed every 10 seconds. In JavaScript, the client creates a new EventSource('/events/weather') and listens on the 'message' event. If the network cable is unplugged and reconnected, the browser automatically sends a new request with the last received event ID, and the server replays missed updates. No polling, no WebSocket upgrade logic.

Related terms

WebSocket HTTP long polling EventSource API text/event-stream push technology

References

More in Web Protocols

CORS

CORS (Cross-Origin Resource Sharing) is a browser security mechanism that lets servers explicitly allow web pages from one origin to request resources from a different origin via HTTP response headers.

GraphQL

GraphQL is a query language and runtime for APIs that lets clients request exactly the data they need in a single round trip, reducing over-fetching and under-fetching.

gRPC

gRPC is a high-performance, open-source remote procedure call framework initially developed by Google. It uses HTTP/2 for transport, Protocol Buffers as its interface definition language and message serialization format, and supports bidirectional streaming.

HTTP

HTTP is a text-based request-response protocol that defines how web clients and servers exchange resources, forming the foundation of data communication on the World Wide Web.

HTTP Pipelining

HTTP Pipelining is a technique in HTTP/1.1 that sends multiple requests on a single connection without waiting for each response, now largely replaced by HTTP/2 multiplexing.

HTTP Status Code

A three-digit integer in an HTTP response that indicates the result of the server's attempt to process the request, grouped into five classes (1xx through 5xx).

HTTP/1.1

HTTP/1.1 is the persistent-connection version of the Hypertext Transfer Protocol, defined in RFC 2616 and updated by RFCs 7230-7235, enabling multiple requests and responses over a single TCP connection.

HTTP/2

HTTP/2 is a binary, multiplexed version of HTTP that reduces latency through header compression, stream prioritization, and server push, as defined in RFC 7540.

HTTP/3

HTTP/3 is the third major version of the Hypertext Transfer Protocol, which runs over QUIC instead of TCP to reduce latency, eliminate head-of-line blocking, and improve connection setup time.

HTTPS

HTTPS (HTTP Secure) is HTTP traffic encrypted inside a TLS session, protecting data confidentiality, integrity, and server authenticity between a client and a web server.

Who Is Online

In total there are 72 users online: 0 registered, 65 guests and 7 bots.

Most users ever online was 5,555 on 17 Jul 2026, 3:23 am.

Bots: AhrefsBot Applebot Baiduspider Bingbot Other Bot PetalBot SemrushBot

Users active in the past 15 minutes. Total registered members: 369