Have you heard of Short Polling and Long Polling, or how large amounts of data are being retrieved without making the client wait? If you don't know these, welcome to the blog. Let's see how it works.
What is Polling?
Here, the client repeatedly asks the server whether new data is available. There are two types of Polling that are: Short Polling and Long Polling.
What is Short Polling?
Short Polling is where requests are sent repeatedly at intervals, and the server responds with whether the request is processed or not.
What is Long Polling?
It is similar to Short Polling, but a request is sent, and the server processes the request and sends the response after the completion of all requests. It may take a fixed time to respond.
What will happen when the client requests a large amount of data to be retrieved?
That's where Server-Sent Events or SSE plays a role.
Think of a 1 Lakh data set, the users request the data to be shown in the application. We know that it takes a lot of time to retrieve the 1 lakh data instantly. Which makes the User Experience bad. To improve the user experience, we send the data in parts. We will divide the 1 lakh data into multiple parts and send one part at a time, not entirely. This makes the user see the results instantly rather than waiting for a long time.
This is what Event Stream is: it is a connection between the client and the server. The connection remains open until the server finishes sending all events. Here, the server sends the chunks of data whenever they become available while keeping the connection open.
Top comments (0)