http - 连接将在 Http/2 中保持多长时间

标签 http networking https keep-alive ttl

连接将在 Http/2 中保持多长时间?
我了解 Http/2 每个域使用一个连接并进行多路复用。但我没有得到有关连接将保持多长时间的任何信息。

最佳答案

与 HTTP/1.1 一样,连接在 HTTP/2 中保持事件的时间取决于客户端和服务器的实现。 HTTP/2 specification

HTTP/2 connections are persistent. For best performance, it is expected that clients will not close connections until it is determined that no further communication with a server is necessary (for example, when a user navigates away from a particular web page) or until the server closes the connection.

[...]

Servers are encouraged to maintain open connections for as long as possible but are permitted to terminate idle connections if necessary. When either endpoint chooses to close the transport-layer TCP connection, the terminating endpoint SHOULD first send a GOAWAY (Section 6.8) frame so that both endpoints can reliably determine whether previously sent frames have been processed and gracefully complete or terminate any necessary remaining tasks.


因此,两个端点都可以通过发送 GOAWAY 优雅地关闭连接。框架。 NginxApache让您配置一个超时,然后关闭空闲的 HTTP/2 连接。 nginx 的默认值为 3 分钟,Apache 的默认值为 5 秒。

关于http - 连接将在 Http/2 中保持多长时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53803772/

相关文章:

wordpress - 4 个页面中的 2 个 WordPress 站点,请求是从 HTTP 发送的。如何将它从 HTTP 更改为 HTTPS?

带参数的http请求

java - 通过网络调试 Java 应用程序

c++ - 如何在qt中解析网络主机名+端口?

ssl - 从 HTTPS 网站检索页面

带有宽卡证书的 iOS POST HTTPS 请求

ruby-on-rails - 使用 ruby​​ 2.5.3 在特定站点上发出获取请求时出现超时错误

没有发布 ASP.NET WebForms 表单 - 为什么?

ios - 在 iOS 应用程序中获取 WAN IP

apache - 将 HTTP 请求重定向到 HTTPS 的推荐方法