Problem
I am wondering how webpush
protocol works? Does it keep some kind of connection open like WebSocket
protocol? Or does it use mechanism similar to polling
?
Tried
According to documentation WebPush uses HTTP 2.0 server push:
A simple protocol for the delivery of real-time events to user agents is described. This scheme uses HTTP/2 server push.
Server push wikipedia:
HTTP/2 Server Push is not a notification mechanism from server to client. Instead, pushed resources are used by the client when it may have otherwise produced a request to get the resource anyway;
HTTP/2 server push example scenario:
Consider a website with three resources: index.html, styles.css and script.js. When a user, through their browser, connects to the home page of this website they automatically retrieve index.html. As the browser parses the HTML text in index.html, it finds instructions that will require styles.css and script.js. At that point, the browser will issue requests to get these other two files.
With HTTP/2 Push, the server can take the initiative by having rules that trigger content to be sent even before it is requested. In this example scenario, the server knows that anyone requesting index.html will need styles.css and script.js, so it can push them to the client immediately without waiting for the client to request them.
According to HTTP/2 server push itt seems that WebPush protocol should return some kind of notifications before they are requested by client. But I am no sure about it. So here is my question: How it exactly works underhood?