http保持连接对同一Web服务器上的不同域有效吗? [英] Is http keep-alive effective with different domain on the same webserver?

查看:114
本文介绍了http保持连接对同一Web服务器上的不同域有效吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

On the same nginx/apache server:

  • 场景1:a.test.com和b.test.com可以使用keep-alive吗?
  • 场景2:本地主机和127.0.0.1可以使用keep-alive吗?

或主机标头"必须保持一致,并且保持活动将有效吗?

or the "Host header" must be consistent and the keep-alive will effective?

推荐答案

对于Apache来说,它看起来是基于IP地址而不是主机标头,尽管我想这也很大程度上取决于客户端的实现.

For Apache it looks like it's based on IP address rather than host header, though I guess it also very much depends on client implementation.

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

持久连接

对于特定的IP地址,上述IP查询仅执行一次 TCP/IP会话,同时在一个请求期间对每个请求进行名称查找 保持活动/持久连接.换句话说,客户可以要求 单个持久性期间来自不同基于名称的虚拟主机的页面 连接.

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进行测试应该很容易,以查看是否花费时间来谈判新连接.

Unless you are using tens of hundreds of domains I'd say you'd struggle to notice either way though it should be easy enough to test using developer tools or webpagetest.org to see if time is spent negotiating a new connection.

这篇关于http保持连接对同一Web服务器上的不同域有效吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆