HTTP 2 的特性
从 HTTP 2 in action 这本书看的, 发现这个网站总结的不错: https://tools.keycdn.com/http2-test, 就摘抄过来了. 顺便测试了一下 (20191104), taobao, ebay 支持 Http2, jd 和 baidu 主页都不支持 HTTP2
- HTTP/2 is binary, instead of textual.
- It is fully multiplexed, sending multiple requests in parallel over a single TCP connection.
- It uses header compression HPACK to reduce overhead.
- It allows servers to “push” responses proactively into client caches instead of waiting for a new request for each resource
- It uses the new ALPN extension which allows for faster-encrypted connections since the application protocol is determined during the initial connection.
- It reduces additional round trip times (RTT), making your website load faster without any optimization.
- Domain sharding and asset concatenation is no longer needed with HTTP/2.
- Flow control
- Stream prioritization
如何判断一个网站是不是支持 HTTP2? 使用最新的 curl 命令:
LM-SHC-16507776:tmp xiatian$ curl -vvv -s --http2 https://www.jd.com:443/ 2>&1 | grep ALPN
* ALPN, offering h2
* ALPN, offering http/1.1
* ALPN, server accepted to use http/1.1
LM-SHC-16507776:tmp xiatian$ curl -vvv -s --http2 https://www.ebay.com:443/ 2>&1 | grep ALPN
* ALPN, offering h2
* ALPN, offering http/1.1
* ALPN, server accepted to use h2
上面的输出中 baidu 首页不支持, ebay 首页支持.
从下面这个问答看:
在 Chrome 里面, 对于 HTTP 2 同一个 origin 不同的 tab 之间共享一个 tcp 连接.
对于 HTTP 1.1:
- HTTP/1.1 sockets are stored in a pool when they are not active. A request from any tab may end up using any socket in the pool;
- Incognito tabs use their own independent socket pool (All incognito tabs for a profile share just one socket pool, though);
- Isolated apps use their own socket pools.
- Different profiles and guest mode use their own socket pools.
- Global requests not tied to a profile use their own socket pool;
https://stackoverflow.com/questions/51535819/in-http-1-1-are-connections-shared-across-multiple-chrome-tabs-to-the-same-origi
https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/S3TEvmRWcNE