The Best Way to Send Data From Backend to Frontend: Server Sent Events
Data Transfer Methods:
There are many ways to transfer data between the server and the client. Let’s look at a few of them in detail!
1.) HTTP connection over TCP: It is a short-lived connection where the client requests for something from the server and the server sends it back to the client immediately and the connection is closed.
2.) Websockets: Opens a pipe between the client and server which allows both of them to simultaneously speak to each other. These are mainly seen in chat applications.
3.) Polling: Polling is kind of a compromise between HTTP and Websockets. Where Polling says I just want to ping the server every few seconds and see if there is any new information and I will keep doing that again and again until I get some kind of new information from the client-side and vice versa, this is an example of short-polling. Long polling on the other hand doesn’t send back a response until and unless it has some new information.
Polling vs Server-Sent Events.
Server-Sent events establish an HTTP connection between the client and the server and create a special form of conveying data between the server and the client in such a way that it opens a connection that is stable using an event source where the server has the ability to send data bidirectionally.
Sharing is caring
Did you like what Agam singh, Aman Ahmed Siddiqui, Aman Chopra, Aman, Amol Shelke, Anas Khan, Anirudh Panda, Ankur Balwada, Anshul Soni, Arif Shaikh, wrote? Thank them for their work by sharing it on social media.
No comments so far
Curious about this topic? Continue your journey with these coding courses:
133 students learning
Husein Nasser
Backend Web Development with Python
109 students learning
Piyush Garg
Master Node.JS in Hindi