Short term polling:
when a client(browser) sends a request to the server , server sends the response to the client and the client waits for it, if there is an update or any data needed the client again sends the request and recieves response
client[waiting.....] --------------------> server
client<------------------------------server[sends response]
client[waiting.....] --------------------> server
client<------------------------------server[sends response]
if update or after sometimes again client sends the request to the server and server response
Long term polling :
when a client sends a request to the server and the server doesnt immediatley response to the client it waits until the data is available or until the wait time is reached. The connection remains open until response is received
client------------------->server[waiting...]
client<------------------sends response(when data is available or it reache the wait time )
server send events:
the server side doesnt sends the entire response directly as it kills user experience so it sends the data batch by batch and reduces the wait time and improve user experience
example: chat gpt
whenever a request is send to gpt it doesnt sends the entire data instead it sends the data patch by patch so it improves user expereince
client-------------->server
client<---------------- data chunk1
client<----------------data chunk2
client<----------------data chunk3
Top comments (0)