HTTP Evolution
The HTTP protocol has evolved over time to better serve the complex web applications of today.
In this short article, we will go over the history of HTTP and the main motivation behind each upgrade without going into a lot of details.
So let's begin …
HTTP 1.0
HTTP 1 was a simple client-server protocol where each HTTP request would create a new TCP connection and close once the server responds to the query.
If you don't have much understanding of TCP then think of it as the channel required to communicate between client and server and each time this channel is created it consumes memory and time. So in short if your frontend is served over HTTP 1.0 it’s going to be pretty slow, as it would require to create a new TCP connection per request.
HTTP 1.1
To improve over HTTP 1, HTTP 1.1 can sustain multiple requests over a single TCP connection. So, if your frontend requests for an HTML doc from the server over HTTP 1.1 then the same TCP connection can be also used to request the Javascript bundle, CSS, etc.
But, there is a catch! Only one request at a time. Until the first request returns the response browser will stall the next request. This is known as HTTP head of line blocking.
To overcome this, most browsers create a max of 6 parallel TCP connections per origin to accommodate parallel requests.
HTTP 2
I think now you can guess the motivation behind HTTP 2. Take a guess. Ok, I will tell.
HTTP 2.0 can support multiple simultaneous requests/response over a single TCP connection. This feature is called Request and response multiplexing.
Requests are broken down into multiple frames which are multiplexed together and sent to the server.
The server assembles the requests at its end from these frames and sends multiplexed response back to the to the client. This way no request is waiting for the other to complete and HTTP 2.0 resolves the HTTP head of line blocking issue.
HTTP 3
This is the latest HTTP protocol and still not widely adopted at the time of writing this article. HTTP 2 though it resolves HTTP head of line blocking issue but it still suffers from TCP head of line blocking issue and that is the main motivation for creating HTTP 3.
HTTP 3 does not use TCP at all but runs over QUIC which is modifications on top of UDP. Understanding difference between TCP and UDP first and then to describe TCP head of line blocking is a article in itself. So, will have it in a later post.
For now, that's all!