DEV Community

Nishanthini T
Nishanthini T

Posted on

Short Polling & Long Polling

Both short polling and long polling are methods in which http requests are done in the client server interaction.

Short polling is the interaction between the client and server where the client sends a request to the server and gets a response immediately. It maybe the actual response that is the data it wanted else the case is when the data is not available. If the data is not available, then the client waits and sends the request again to get its response from the server. The waiting and sending request is done by the client here. So in short polling multiple connections are made between the client and server.

Long polling is where the client sends request to the server and the server waits for the data to be free and then gets the response and gives to the client. The server waits for mentioned period of time for receiving the data and sends the response to the client. Hence in long polling less connections are made between the client and server.

*Event Stream * - When a request is sent to the server and the response for it is not generated and sent as a whole, it is generated in parts or segments which are then and then sent to the client as response which is known as event stream. For example, Chatgpt generated the response for our query line by line and not as a whole patch of answer.

Top comments (0)