100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

HTTP/2 vs HTTP/1.1: What Changed?

HTTP/2 vs HTTP/1.1 explained — multiplexing, HPACK header compression, and remaining limits — with code and interview questions answered.

mediumQ20 of 224 in Computer Networks Est. time: 5 minsLast updated:
Open Code Lab

Expected Interview Answer

HTTP/2 replaces HTTP/1.1’s text-based, one-request-per-connection model with a binary framing layer that multiplexes many requests and responses over a single TCP connection, eliminating head-of-line blocking at the HTTP layer and adding header compression and server push.

HTTP/1.1 sends plain-text requests and, without pipelining hacks, opens multiple TCP connections (typically 6 per host) to fetch resources in parallel, wasting handshake and slow-start overhead on each one. HTTP/2 introduces binary frames grouped into streams, so dozens of requests and responses interleave over one connection, and HPACK header compression removes the repeated, verbose header text HTTP/1.1 resends on every request. Server push lets the server proactively send resources it knows the client will need, though most implementations have since deprecated it in favor of preload hints. The trade-off interviewers probe is that HTTP/2 still rides on TCP, so a single lost packet can still stall every multiplexed stream — a problem HTTP/3 fixes by moving to QUIC over UDP.

  • Multiplexing removes HTTP-layer head-of-line blocking
  • HPACK header compression cuts repeated header overhead
  • Single connection reduces handshake and slow-start cost
  • Binary framing is more efficient to parse than text

AI Mentor Explanation

HTTP/1.1 is like a stadium with six ticket windows, each serving one fan at a time before the next can approach — plenty of queuing even though six lines run in parallel. HTTP/2 is like a single smart counter that takes every fan’s request at once, tags each ticket with a number, and hands tickets back in whatever order they finish, so nobody waits behind a slow request. The staff also stop repeating the stadium’s full address on every ticket once they have said it once, saving time on every exchange.

Step-by-Step Explanation

  1. Step 1

    Framing

    HTTP/2 wraps requests and responses in binary frames instead of plain text.

  2. Step 2

    Multiplexing

    Many streams share one TCP connection, interleaving frames by stream ID.

  3. Step 3

    Header compression

    HPACK avoids resending identical headers on every request.

  4. Step 4

    Trade-off

    Still on TCP, so one lost packet can stall all streams — HTTP/3 (QUIC) fixes this.

What Interviewer Expects

  • Understanding that HTTP/2 multiplexes over one connection
  • Knowing HPACK reduces header overhead
  • Awareness that HTTP/2 still inherits TCP head-of-line blocking
  • Mentioning HTTP/3 and QUIC as the next evolution

Common Mistakes

  • Claiming HTTP/2 removes all head-of-line blocking
  • Confusing HTTP/2 multiplexing with multiple TCP connections
  • Forgetting HTTP/2 requires binary framing, not text
  • Not knowing server push has largely been deprecated

Best Answer (HR Friendly)

HTTP/2 lets a browser fetch many parts of a page over a single connection at the same time instead of opening several separate connections and waiting in line on each one, which makes pages load faster, especially on sites with lots of small files like icons and scripts.

Code Example

Checking the HTTP protocol version with curl
# Force HTTP/1.1 and inspect the response
curl -I --http1.1 https://example.com

# Force HTTP/2 and compare
curl -I --http2 https://example.com

# curl -v shows the negotiated ALPN protocol during TLS handshake
curl -v --http2 https://example.com 2>&1 | grep -i "ALPN"

Follow-up Questions

  • What is head-of-line blocking and why does HTTP/2 still suffer from it?
  • How does HTTP/3 use QUIC to solve HTTP/2’s remaining limitations?
  • What is HPACK and how does it compress headers?
  • Why was HTTP/2 server push mostly deprecated by browsers?

MCQ Practice

1. What is the primary mechanism HTTP/2 uses to avoid opening multiple TCP connections?

HTTP/2 multiplexes many request/response streams over a single TCP connection.

2. Which compression technique does HTTP/2 use for headers?

HPACK is the header-specific compression format defined for HTTP/2.

3. What underlying limitation does HTTP/2 still inherit because it runs over TCP?

A single lost TCP packet can stall all multiplexed streams, since TCP guarantees strict order.

Flash Cards

HTTP/2 in one line?Binary, multiplexed HTTP over a single TCP connection with header compression.

What is HPACK?HTTP/2’s header compression format that avoids resending identical headers.

HTTP/2’s remaining weakness?TCP-layer head-of-line blocking from packet loss, since it still uses TCP.

What fixes HTTP/2’s TCP weakness?HTTP/3, which runs over QUIC (UDP-based) instead of TCP.

1 / 4

Continue Learning