Time To Live on Server Side Events

As mentioned in the course, huge number of blank request-response cycles are cut down in SSE, but will it affect the connection, if there is no request-response cycle, will browser kill the connection due to TTL?

Type your question above this line.


@ABHIJEET_SHUKLA Modern browsers support SSE technology. Clients are connected with the SSE server by keep-alive event stream, a uni-directional connection that isn’t closed until browser/tab is closed, the user invokes the close method or the network connection is lost. The server sends the HTTP response headers to tell the client that an event stream is starting. When the browser knows that it’s an event stream it doesn’t close the connection.

Moreover, a unique id is set with every event. This lets the browser keep track of the last event fired so that if, the connection to the server is dropped, a special HTTP header (Last-Event-ID ) is set with the new request. The browser attempts to reconnect to the source roughly 3 seconds after each connection is closed. You can also tweak the time in the code.

1 Like