educative.io

HTTP Push-Based Technologies - Web Application & Software Architecture 101

I am confused with following statement stated by author under HTML5 Event Source API & Server Sent Events push technology.

" This helps in getting rid of a huge number of blank request-response cycles cutting down the bandwidth consumption by notches."

What i understood from author conversation about push technology is to establish persistent connection, we should have some sought of mechanism where browser should not kill the open connection if request - response flow crosses TTL. This mechanism can be achieved by using Heart beat Interceptors, these are just blank request responses between the client and the server to prevent the browser from killing the connection.

Here is my question, how HTML5 Event Source API & Server Sent Events helps in keeping persistent connection between client and server without blank request-response cycles (heart beat interceptor) ? Thanks in advance.

Regards,
Indra

@Indra

What i understood from author conversation about push technology is to establish persistent connection, we should have some sought of mechanism where browser should not kill the open connection if request - response flow crosses TTL.

That’s correct. To establish a persistent connection with the server, the browser should keep the connection open. And to implement Server Sent Events both the browser and the server should support the SSE technology. If the browser supports the HTML5 Event Source API it will keep the connection open, after it sends an initial request to establish a connection with the server. Once
a connection is established browser becomes a listener to the stream of events sent from the server.

In this use case, there is no need for the browser to send blank requests to the server to keep the connection open. The connection stays open until the client explicitly invokes the connection close method or the user closes the browser tab or the network connection is lost. In the network connection lost situation, the connection to the server is restarted by the browser.

Let me know if you have any further questions. I’ll be happy to answer them.

2 Likes

@Shivang
Follow up question. In the event of a lost connection, is the connection restarted by the browser automatically or does it have to be initiated by a triggered action by the user?

@Nedu_Robert

The connection is automatically restarted by the browser.