About HTTP Protocol

HTTP(Hypertext Transfer Protocol)is an application level transfer protocol based on TCP/IP. It's been used to transfer mainly html pages, also css, javascipt files and other media files like images and videos. Actually it doesn't care what it is transferring since all files will be encrypted and compressed into just binaries.

Stateless

HTTP protocol is a stateless protocol(In contrast, TCP is stateful). Meaning that every request is independent for both server and client even using the same TCP connection. They don't know what happened in the last request or there is no 'last request' idea.

Real applications or websites use cookie and session to maintain the stateful information like user, shopping cart. Notice that this stateless idea is not conflict with 'keep-alive' in HTTP protocol that indicates the TCP connection is not going to be closed after a http request finishes. So multiple HTTP requests will reuse the TCP connection reducing some cost for opening and closing a TCP connection. Meanwhile, the server still doesn't know that these requests come from the same client(maybe the same IP address but possibly not the same client).

Keep-alive is usually disabled on many web servers since it will hold on a connection for a relatively long time. Eventually the server will run out of connections because all connections are being hold on.

However, there are circumstances where keep-alive can improve performance. If your website deploys behind a load balancer or cloud firewall like cloudflare. Keeping connections between your website and the middleware alive will be a good choice since the amount of middleware should be limited, and you won't run out of connections.