HTTP the acronym for Hypertext transfer protocol is an application layer protocol used for transmitting hypermedia documents, such as HTML. It was primarily designed for making the communication between web browsers and web servers, but it is not limited to the same. HTTP follows a classical client-server model with a client opening a connection to make a request, then waiting until it receives a response. The HTTP server does not keep any data between two requests i.e it is a stateless protocol. As it is based on the TCP/IP layer, it can be used on any reliable transport layer.
HTTP/2 was released in 2015 as a major revision to the HTTP/1.1 protocol. It was derived from the SPDY protocol as a way to improve the online experience by speeding up page loads and reducing round-trip-tome, especially on resource-heavy web pages. HTTP/1 was the third version of HTTP and the standard protocol for 15 years. It introduced persistent connections for improved performance and laid the foundation for standard requests. Such as GET, HEAD, PUT and POST.
As websites become more resource-intensive, however, HTTP/1.1’s limitations began to show. Specifically, its use of one outstanding request per TCP connection created significant overhead, slowing down page load times.
In 2010, Google released the SPDY protocol as a way of modifying how HTTP handles requests and responses. Its focus was on reducing latency via PIPELINING and providing mandatory compression, amongst other features.
While HTTP/2 was initially modeled after SPDY, it was soon modified to include unique features, including a fixed header compression algorithm.
HTTP/2 improved HTT/1.1 in several ways that allowed for speedier content delivery and improved user experience, including:
Binary Protocol: Binary protocols consume less bandwidth, are more efficiently parsed, and are less error-prone than the textual portal used by HTTP/1.1. Additionally, they can better handle elements such as whitespace, chaptalization, and line endings.
Multiplexing – HTTP/2 is multiplexed, i.e., it can initiate multiple requests in parallel over a single TCP connection. As a result, web pages containing several elements are delivered over one TCP connection. These capabilities solve the head-of-line blocking problem in HTTP/1.1, in which a packet at the front of the line blocks others from being transmitted.
Header compression – HTTP/2 uses header compression to reduce the overhead caused by TCP’s slow-start mechanism.
Server push – HTTP/2 servers push likely-to-be-used resources into a browser’s cache, even before they’re requested. This allows browsers to display content without additional request cycles.
Increased security – Web browsers only support HTTP/2 via encrypted connections, increasing user and application security.
Web sockets are bidirectional, a full-duplex protocol that is used in the same scenario of client-server communication, unlike HTTP it starts from ws:// or was:// .It is a stateful protocol, which means it keeps track of the data between the network calls and will stay alive until either client or the server breaks the connection.