Back

Himanshu Singh

 • 

Wherehouse • 11d

Explaining Server Sent Events! Server-Sent Events (SSE) is a technology that lets a web server send real-time updates to a client, like a browser, over a single, long-lasting HTTP connection. It’s a simple, efficient way to push data from the server to the client without the client needing to ask for it repeatedly. Think of it as a one-way stream where the server can keep sending new information—like notifications, live scores, or stock prices—whenever it wants. SSE is built on standard HTTP, making it easy to use with existing web tools, and it’s different from WebSockets, which allow two-way communication. Here, the data only flows from server to client. What Is SSE and Why Use It? Imagine you’re waiting for a text message. You don’t keep texting your friend every second to check if they’ve replied—you just wait for their message to arrive. SSE works similarly. Instead of the client (browser) constantly polling the server with “Do you have anything new?” requests, the server holds the connection open and sends updates as they happen. This saves bandwidth, reduces server load, and makes things feel instant for the user. SSE is perfect for things like: Showing live news updates. - Displaying real-time stock prices. - Sending chat notifications. - Updating a dashboard with server stats. It’s lightweight, uses plain HTTP, and doesn’t need fancy setups, unlike WebSockets, which are more complex and bidirectional. How Does SSE Work? Here’s the basic flow: Client Connects: The browser starts the process by connecting to a server endpoint (e.g., /events) using a tool called EventSource (a JavaScript API). Server Responds: The server says, “Okay, I’ll keep this line open,” and sets up the connection with special headers to tell the browser it’s sending an event stream. Data Flows: The server sends messages whenever there’s something new. These messages are simple text, separated by blank lines. Client Listens: The browser catches these messages and does something with them—like updating the webpage. The connection stays open until either the client or server closes it. If it drops (say, due to a network glitch), the client can automatically reconnect.

3 replies5 likes
Replies (3)

More like this

Recommendations from Medial

Himanshu Singh

 • 

Wherehouse • 11d

**🚀 Understanding WebSockets in 5 Points** 1️⃣ **Real-Time Communication**: WebSockets enable two-way, real-time communication between a client (e.g., browser) and a server, unlike traditional HTTP requests which are one-way and stateless. 2️⃣

See More
0 replies

Vansh Khandelwal

Full Stack Web Devel... • 26d

Socket.IO simplifies real-time, bi-directional communication, ideal for apps like chat platforms, collaborative tools, and live trackers. Built on WebSockets, it offers cross-browser support, automatic reconnection, and event-based architecture. With

See More
0 replies2 likes

biswa

Busy • 10m

Does rider side apps for Zomato or swiggy have a persistent connection with the server to update their live location to get the nearest order pickup ?

0 replies2 likes
Image Description
Image Description

Aurobindo Patra

ezeslucky • 10m

As a Web dev, do you prefer client-side rendering or server-side rendering?

2 replies3 likes
Image Description
Image Description

Sunil Sharma

Exploring the world ... • 11m

The most interesting browser is now available for windows. Its a complete replacement of chrome. It comes up with various feature like space creation to separate out your work profile and personal profile which help you out with productivity. This br

See More
4 replies6 likes
1

Vasvi Seth

Cyber Security Stude... • 8m

Exploring Communication Protocols: Transmission Control Protocol (TCP) Communication protocols are the cornerstone of network transmission, dictating how data is exchanged between devices. They ensure efficient and reliable communication, including

See More
0 replies5 likes

Somen's 8D world

Hey I am on Medial • 10m

I don't know any stateless messageing system which can send data from server to client without steady client connection like websocket. so I built one. and name it RTCserver. it uses fcm and webrtc in a clever way to send server data to client. and

See More
0 replies3 likes

biswa

Busy • 10m

So I was building a dating + social media for mainly colleges, coded the full site > friendcity.in Coded the client in react and the backend on server less architecture, used hono and cloud flare workers, server less require you to db pooling so use

See More
0 replies6 likes
Image Description
Image Description

Utkarsh Agarwal

 • 

Insight Enterprises • 9m

Hey all, I am trying to apply webOTP in my react js application for easy read of otp in mobile browser. I am using this code which is giving a prompt on the browser(only chrome) for allowing to read messages but after allowing its not setting up the

See More
6 replies6 likes
Image Description

Payal Manghnani

#uiux designer #free... • 2m

🤖 The only 7 AI tools you need to 10x your productivity in seconds. 🤖 1. YouTube Summaries ✅http://eightify.app 2. Photo Editor ✅http://picwish.ai 3. Website Builder ✅http://mixo.io 4. Voice Notes ✅http://vribble.ai 5. Text Notes ✅http://albus

See More
1 replies6 likes
7

Download the medial app to read full posts, comements and news.