Http Vs Http2

Http 1.1 allows clients to make a connection to a server and issue commands such as get resources. Http is uni directional where client is issuing requests to server and not vice versa. Http is stateless meaning that there is no direct link between one http request and another, but http does allow use of stateful sessions via cookies. Http requires a reliable underlying transmission protocol such as tcp.  

Http 2 differs from http1 in that:

  • Binary framing: unlike newline delimited plaintext http/1.x http/2 communicates via splitting messages into small frames which are binary encoded.
  • Supports streams: a bidirectional flow of messages can carry one or more messages
  • Connections: Http2 can transmit multiple streams over a single connection
  • Stream prioritization: client can build a dependency weighted tree which the server can prioritize to send the messages to the client.
  • Multiplexing: http/1.x loads resources sequentially over a single TCP connection or for parallel load uses more than one TCP connection. Http2 can send multiple resources at once over different streams.
  • Server push: http2 supports the ability to send back to the client more than what it requested thereby enabling faster loads. For example, if the client requested a page and then later requests an image on the page, the request to load the image will be a separate request on http/1.1 while http2 when sending the page can also send the image to the client assuming the client will later request the image in addition to the text.
  • Header compression: http2 uses an efficient hpack based compression to compress the messages.

From Google: “http2 breaks down the http protocol communication into an exchange of binary-encoded frames, which are then mapped to messages that belong to a particular stream, all of which are multiplexed with a single tcp connection. This is the foundation that enables all other features and performance optimizations provided by http2 protocol.”

Reference:

https://developers.google.com/web/fundamentals/performance/http2