HTTP/2 vs HTTP/1

What is HTTP?

Hypertext Transfer Protocol (HTTP) is an application protocol that is, currently, the foundation of data communication for the World Wide Web.

HTTP is based on the Client/Server model. Client/Server model can be explained as two computers, each with their own IP address.

The client (receiver of service) and Server (provider of service) that are communicating via requests and responses.

A simple and abstract example would be a restaurant guest and a waiter. The guest (Client) asks (sends request) waiter (Server) for a meal, then the waiter gets the meal from the restaurant chef (your application logic) and brings the meal to the guest.

This is a very simplistic example, but it is also the one that will help you understand the concept.

  What is HTTP/2?

In 2015, Internet Engineering Task Force (IETF) released HTTP/2, the second major version of the most useful internet protocol, HTTP.

Main goals of developing HTTP/2 was:

  • Protocol negotiation mechanism – protocol electing, eg. HTTP/1.1, HTTP/2 or other.
  • High-level compatibility with HTTP/1.1 – methods, status codes, URIs and header fields.
  • Page load speed improvements  trough:
    • Compression of request headers
    • Binary protocol
    • HTTP/2 Server Push
    • Request multiplexing over a single TCP connection
    • Request pipelining
    • HOL blocking (Head-of-line) – Package blocking
  • Low overhead in parsing data – a critical value proposition in HTTP/2 vs HTTP/1.
  • Less prone to errors.
  • Lighter network footprint.
  • Effective network resource utilization.
  • Eliminating security concerns associated with the textual nature of HTTP/1.x such as response splitting attacks.
  • Enables other capabilities of the HTTP/2 including compression, multiplexing, prioritization, flow control and effective handling of TLS.
  • Compact representation of commands for easier processing and implementation.
  • Efficient and robust in terms of processing of data between client and server.
  • Reduced network latency and improved throughput.
HTTP/2 Server Push

This capability allows the server to send additional cacheable information to the client that isn’t requested but is anticipated in future requests. For example, if the client requests for the resource X and it is understood that the resource Y is referenced with the requested file, the server can choose to push Y along with X instead of waiting for an appropriate client request.

If you remember the story about a guest in a restaurant and waiter, that would be an example for HTTP/1.1 and HTTP/2 protocol with a slight difference. Imagine that waiters are TCP connections and you want to order your meal and a bottle of water. For HTTP/1.1 that would mean that you ask one waiter for your meal and another one for water, hence you would allocate two TCP connections. For HTTP/2 that would mean that you ask only one waiter for both, but he brings them separately. You only allocate one TCP connection and that will already result with lower server load, plus the server would have one extra free connection (waiter) for the next client (guest).

The real difference between HTTP/1.1 and HTTP/2 comes with server push example.


Imagine that the guest (Client) asks (sends request) waiter (Server) for a meal, then the waiter gets the meal from the restaurant chef (your application logic), but the waiter also thinks you would need a bottle of water so he brings that too with your meal. The end result of this would be only one TCP connection and only one request that will significantly lower the server load.


You may also like

November 6, 2023

Maximizing Your IT Internship: The Role of Mentor

When it comes to software engineering, making the leap from the classroom to the real-world industry can be a thrilling yet daunting adventure. Recent graduates navigate uncharted territory, facing complex tech challenges. They often find that practice deviates from their perception of how a task is approached and performed in the workplace. But here at […]

November 27, 2023

Effective Remote Work: How to Enhance Your Soft Skills

Remote work, once celebrated for its conveniences like working from the comfort of home and the absence of daily commutes, can be a double-edged sword. On one side lies the allure of a familiar environment, while on the other, the potential for disconnected team members and a disjointed workflow looms.  So that’s where soft skills […]

November 20, 2023

Top IT Skills in Demand in 2024

In the ever-racing tech arena, staying in the loop isn’t a choice—it’s a must. Whether you’re a seasoned software developer aiming to maintain your edge, a practitioner honing your skills, or a job hunter gearing up for crucial interviews, you’ve got to ride the trend wave.  Join us on a journey into the most sought-after […]