When using SSE through the HTML5 EventSource object, do the requests utilise the HTTP/2 multiplexing / pipelining features? In particular, will SSE requests in different tabs (re)use the same HTTP/2 connection?
I assume so, since SSE is based (AFAIK) on HTTP/1.1 chunked_encoding technology, but wanted to check.
Yes they will. Chrome's http2 tag is a great way to explore how http2 requests are emitted: chrome://net-internals/#http2.
For the requests emitted by SSE, you should see something like:
HTTP2_SESSION_SEND_HEADERS
--> exclusive = true
--> fin = true
--> has_priority = true
--> :method: GET
:authority: h2.example.org
:scheme: https
:path: /demo_sse.php
accept: text/event-stream
cache-control: no-cache
referer: https://h2.example.org/
accept-encoding: gzip, deflate, sdch, br
accept-language: en-US,en;q=0.8,fr;q=0.6,es;q=0.4
--> parent_stream_id = 0
--> priority = 1
--> stream_id = 7
As you can see in this example, the browser sent the request on stream id 7, re-using the connection it had to fetch the html.
Theoretically, yes. And, in practice the answer should be the same, as most browsers have implemented SSE on top of their XmlHttpRequest2
object.
(To be fair, I've not found a definitive reference that says AJAX requests to the same origin are shared across tabs, but it is hard to imagine why a browser would not have allowed that - I've not managed to come up with a security reason, for instance.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With