Modern web applications often need to send information from a server to a client as soon as an event occurs. Examples include chat messages, live notifications, stock prices, sports scores, and real-time dashboards. Traditional HTTP communication usually requires the client to request information from the server. However, technologies such as WebSocket and Server-Sent Events (SSE) make real-time server-to-client communication possible.
What Is HTTP Server Push?
HTTP server push, in the context of web applications, refers to techniques that allow a server to deliver new information to a client without requiring the client to repeatedly make separate requests.
Traditional communication works like this:
Client → Request → Server → Response → Client
For frequently changing information, repeatedly making requests can be inefficient. WebSocket and SSE provide alternatives that allow the server to deliver updates when they become available.
WebSocket
WebSocket provides a persistent, two-way communication channel between a client and a server. After establishing a connection, both sides can send messages independently.
The connection begins with an HTTP request and an upgrade process. Once the connection is established, communication continues using the WebSocket protocol.
The basic communication model is:
Client ↔ WebSocket Server
This makes WebSocket particularly useful for applications where both the client and server need to communicate in real time.
Advantages of WebSocket
-
Supports two-way communication.
-
Provides low-latency communication.
-
Allows the server to send data whenever necessary.
-
Suitable for interactive real-time applications.
-
Can handle frequent messages efficiently.
Common Uses of WebSocket
WebSocket is commonly used for:
-
Online chat applications
-
Multiplayer games
-
Collaborative editing
-
Real-time dashboards
-
Live trading applications
-
Interactive notifications
For example, in a chat application, a WebSocket connection can remain open between the browser and server. When one user sends a message, the server can immediately send that message to other connected users.
Server-Sent Events (SSE)
Server-Sent Events, commonly called SSE, provide a simpler mechanism for sending real-time updates from a server to a web browser.
Unlike WebSocket, SSE is primarily one-way communication:
Server → Client
The browser establishes a long-lived HTTP connection using the EventSource API. The server keeps the connection open and sends events whenever new information is available.
A simple JavaScript example is:
const events = new EventSource("/events");
events.onmessage = (event) => {
console.log("New update:", event.data);
};
The server can then send events over the open connection.
Advantages of SSE
-
Simple to implement for server-to-client updates.
-
Uses standard HTTP.
-
Automatically supports reconnection in browsers.
-
Works well with text-based event streams.
-
Uses the browser’s built-in
EventSourceAPI.
Common Uses of SSE
SSE is useful for:
-
Live notifications
-
News feeds
-
Real-time monitoring
-
Progress updates
-
Live dashboards
-
Streaming status information
For example, a server could use SSE to continuously send the latest temperature or system status to a browser.




