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

北城余情 提交于 2019-12-12 02:45:53

问题


On the same nginx/apache server:

  • Scene 1: a.test.com and b.test.com can use keep-alive?
  • Scene 2: localhost and 127.0.0.1 can use keep-alive?

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


回答1:


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

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.

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.



来源:https://stackoverflow.com/questions/35532480/is-http-keep-alive-effective-with-different-domain-on-the-same-webserver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!