Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The difference between long connection and short connection in HTTP

Shulou Source: shulou.com Published: 2022-06-02 06:31:41 10月19日 Update

This article mainly explains the difference between long connection and short connection in HTTP. The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the difference between long connection and short connection in HTTP.

Short connections are used by default in HTTP/1.0. In other words, every time the client and server perform a HTTP operation, a connection is established, and the connection is interrupted at the end of the task. When a client browser accesses a HTML or other type of Web page that contains other Web resources (such as JavaScript files, image files, CSS files, etc.), every time such a Web resource is encountered, the browser will re-establish a HTTP session.

From HTTP/1.1, long connections are used by default to maintain the connection characteristics. Using the long-connected HTTP protocol, this line of code is added to the response header:

Connection:keep-alive

In the case of a persistent connection, when a web page is opened, the TCP connection used to transmit HTTP data between the client and the server will not be closed, and when the client accesses the server again, it will continue to use this established connection. Keep-Alive does not stay connected permanently, it has a hold time, which can be set in different server software (such as Apache). The realization of persistent connection requires that both client and server support persistent connection.

Thank you for reading, the above is the content of "the difference between long connection and short connection in HTTP". After the study of this article, I believe you have a deeper understanding of the difference between long connection and short connection in HTTP, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Client client service server file learning content situation time browser resource browse different between that is to say code task again image Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia OPPO Reno Microsoft Apple