How does the browser decide whether to use HTTP1 or HTTP2 for a request?

HTTP2 is well known to be very convenient, multiplexing, binary protocol, priority control, server push, header compression, so in the browser, how do you know whether a request uses http1 or http2?

Is it possible to try it with http1 first, and ask if it can be upgraded, and then it can be upgraded to http2? Does that sound slow? One more request is required.
Or the browser stores a table locally, which stores the server ip + request url, and records which ones support http2? But this cost seems to be quite large, unrealistic.

After checking the article, I found out that
insert image description here
https://hpbn.co/http2/
negotiates whether http2 can be used during tls handshake, so that it will not cause waste, but this also makes https seem to be tied to http2 The same thing together, in fact, both chrome and firefox must use https if they want to use http2.

There are also big shots in China who have captured and analyzed
https://imququ.com/post/protocol-negotiation-in-http2.htmlinsert image description here

Guess you like

Origin blog.csdn.net/ZhaoBuDaoFangXia/article/details/121772935