Server Sent Event (SSE) is a mechanism where a client (browser) receives automatic updates from a server via a long-living HTTP connection that was established when the client contacted the server for the first time. The SSE client subscribes to a stream of updates generated by a server, and whenever a new event occurs, a notification is sent to the client via the existing HTTP connection. The connection is then left open until the server has some data to send. In this section, we will discuss how the SSE technology can be used in a REST API to send continuous updates to the client.
Tip
Server Sent Events use a single, unidirectional, persistent connection between the client and the server. This is suited for the one-way publish-subscribe model wherever the server pushes updates to clients.
In a typical HTTP client-server communication model, the client opens the connection and sends a request to the server. The server then responds back...