LLMpediaThe first transparent, open encyclopedia generated by LLMs

Server-Sent Events

Generated by GPT-5-mini
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Parent: MicroProfile Hop 4
Expansion Funnel Raw 90 → Dedup 0 → NER 0 → Enqueued 0
1. Extracted90
2. After dedup0 (None)
3. After NER0 ()
4. Enqueued0 ()
Server-Sent Events
NameServer-Sent Events
TitleServer-Sent Events

Server-Sent Events Server-Sent Events is a web technology for unidirectional, real-time data streaming from a server to a client using HTTP. It enables a persistent connection over which a server can push updates to a browser or other HTTP client without the client repeatedly polling, fitting alongside technologies like WebSockets, HTTP/2, and WebRTC. Major implementations and deployments intersect with projects and organizations such as Mozilla, Google, Microsoft, Apple, Apache HTTP Server, Nginx, Cloudflare, Amazon Web Services, and standards bodies including the World Wide Web Consortium and the Internet Engineering Task Force.

Overview

SSE provides a simple event-stream model that leverages existing HTTP infrastructure and the EventSource interface defined by browser vendors and standards groups. Clients establish a long-lived GET request and receive text/event-stream encoded messages, enabling server-initiated updates for applications managed by teams at Facebook, Twitter, LinkedIn, Netflix, Spotify, and other platforms. SSE is often chosen where integration with HTTP/1.1, TLS, CDNs operated by Fastly or Akamai is important, and it complements architectures using RESTful APIs, GraphQL endpoints maintained by organizations like Shopify or GitHub.

History and standardization

The model traces to early push proposals from browser and standards communities including engineers affiliated with Mozilla and WHATWG. Formalization occurred through collaborations among contributors associated with W3C and WHATWG mailing lists and implementers from Google Chrome and Mozilla Firefox teams. Adoption grew as content delivery services from companies such as Akamai Technologies and cloud providers like Amazon integrated long-polling and streaming patterns. The EventSource API and text/event-stream media type were discussed alongside competing real-time efforts like WebSocket and later developments in HTTP/2 spearheaded by contributors from NGINX and Google.

Protocol and technical details

SSE uses the MIME type text/event-stream over an HTTP GET request, with a persistent connection that conveys UTF-8 encoded lines. Event frames contain fields such as "data", "id", and "event", and use line separators compatible with implementations in Chromium, Gecko, and WebKit engines developed by teams at Google, Mozilla Foundation, and Apple Inc.. The protocol supports reconnection via the "retry" field and last-event-id handling for resumable streams, useful in systems designed by enterprises like IBM and Microsoft Corporation. SSE works with transport-level security provided by Transport Layer Security implementations from vendors including OpenSSL, BoringSSL, and LibreSSL, and can interoperate with reverse proxies and load balancers from HAProxy, F5 Networks, and Cisco Systems.

Use cases and comparison to alternatives

SSE is suited for feed-like updates and server-originated notifications such as live news ticks, stock tickers, collaborative document presence indicators, and monitoring dashboards used by teams at Bloomberg L.P., The New York Times, Reuters, GitLab, Atlassian, and Datadog. Compared to WebSocket—adopted in systems by Slack and Trello—SSE is unidirectional and simpler to integrate with HTTP caches and CDNs from Cloudflare or Fastly, while WebSocket provides full-duplex channels favored in gaming backends by studios like Epic Games or Unity Technologies. Alternatives like long polling were popularized in legacy stacks from Yahoo! and Microsoft Exchange; HTTP/2 server push, promoted by Google and Mozilla', targets different use cases such as resource preloading.

Implementation and browser support

Native EventSource implementations ship in major browsers including Google Chrome, Mozilla Firefox, Apple Safari, and Microsoft Edge (Chromium-based), as developed by teams at Google, Mozilla Foundation, Apple Inc., and Microsoft Corporation. Polyfills and libraries from maintainers associated with ecosystems like Node.js, Deno, Spring Framework by Pivotal Software, and Express.js communities add support for older browsers. Server-side frameworks and servers with SSE modules include Node.js, Ruby on Rails, Django from The Django Software Foundation, ASP.NET from Microsoft, Go standard library contributors, and reverse proxies like NGINX and Apache HTTP Server.

Security and scalability considerations

SSE connections are subject to authentication and authorization patterns used by systems at OAuth-enabled platforms like Google, Facebook, and GitHub; integration often uses cookies, bearer tokens, or signed URLs issued by services such as Okta or Auth0. Scalability techniques mirror large deployments at Netflix and Amazon: connection pooling, sharding, horizontal scaling with container orchestration from Kubernetes (originated by engineers from Google), and connection offloading via dedicated proxy tiers from Envoy contributors at Lyft. Security hardening leverages TLS configurations recommended by IETF and certificate authorities like Let's Encrypt; defenses against injection and replay attack vectors align with practices promoted by OWASP.

Example code and common patterns

Typical client usage relies on the EventSource constructor available in browsers maintained by Google, Mozilla Foundation, and Apple Inc.:

- Initialize an EventSource to a server endpoint handled by frameworks like Node.js or Django. - Listen for "message", custom event types, and "error" events, and use "last-event-id" logic aligned with reconnection semantics implemented by infrastructure teams at Cloudflare and Akamai. - Server implementations stream "data:" lines and flush buffers in HTTP responses within servers like NGINX, Apache HTTP Server, or application servers such as Gunicorn and Puma.

Common patterns include heartbeat comments for connection liveness used by engineering groups at Twitter and Instagram, multiplexing logical channels via "event" fields inspired by real-time systems at Slack and Discord, and integrating SSE endpoints with observability stacks like Prometheus and Grafana for metrics and health insights.

Category:Web technologies