http keep-alive 是否对同一网络服务器上的不同域有效?

Is http keep-alive effective with different domain on the same webserver?

在同一个 nginx/apache 服务器上:

或者"Host header"必须一致,保活才有效?

对于 Apache,它看起来像是基于 IP 地址而不是主机 header,但我猜它在很大程度上也取决于客户端实现。

https://httpd.apache.org/docs/2.4/vhosts/details.html#hostmatching

Persistent connections

The IP lookup described above is only done once for a particular TCP/IP session while the name lookup is done on every request during a KeepAlive/persistent connection. In other words, a client may request pages from different name-based vhosts during a single persistent connection.

除非您使用的是成百上千个域,否则我会说您很难注意到这两种方式,尽管使用开发人员工具进行测试应该很容易,或者 webpagetest.org 看看是否花时间协商一个新的连接。