Real-Timechapter 3 of 4 · 3 lessons
Server-Sent Events (SSE)
One HTTP connection; server streams events to client indefinitely.
Server-Sent Events is push with the smallest possible surface: one long-lived response that your server keeps writing events into.
It is the least famous of the four techniques here and arguably the best default for the most common need, a server that talks and a client that listens. Being the least famous is most of why teams skip it, reaching instead for the option they have heard of, then spending a quarter building reconnection logic that was already in the box.
Lessons
3 in this chapter- The Event Stream ProtocolOne GET response that never ends, carrying plain-text events separated by blank lines.2 min
- Reconnection and Last-Event-IDThe browser reconnects and resumes by itself, if your server can answer the replay question.2 min
- SSE vs WebSocketIf the client rarely talks, SSE does the same job with a fraction of the operational surface.2 min