Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save whatwewant/2e0091ac5d27ec1481540a8b9bc3ec3a to your computer and use it in GitHub Desktop.
Save whatwewant/2e0091ac5d27ec1481540a8b9bc3ec3a to your computer and use it in GitHub Desktop.

keep-alive

是什么

  • 省略

为什么

  • 1 keep-alive 目的是在过期时间内保持浏览器端与服务器端间的连接
  • 2 是TCP层面的,保持TCP连接不关闭,而不是保持http连接不关闭;
  • 3 keep-alive是串行的不是并行的;

怎么做

  • 从HTTP 1.1开始,浏览器请求默认会带上Connection: keep-alive请求头;
  • 服务器会返回Connection: keep-alive,如果要关闭,服务器要返回Connection: close;

对比

  • keep-alive与http2的多路复用(multiplexing)技术: keep-alive是串行的,多路复用是并行的

相关资源

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment