What are the main differences between HTTP/1.1 and HTTP/2?
HTTP/2 uses a binary format, multiplexes many requests over a single TCP connection, compresses headers with HPACK and allows prioritisation. HTTP/1.1 is plain text and handles one request at a time per connection, so browsers open several connections instead.
Explain it simply
HTTP/1.1 is a single-lane shop counter where each customer waits for the previous one to be fully served, so the shop opens six counters. HTTP/2 is one counter where the clerk handles many customers' items interleaved, so no extra counters are needed.
Example
HTTP/1.1 HTTP/2
Format text binary frames
Connections about 6 per host 1 per host
Concurrency one request at a time many streams multiplexed
Headers repeated in full HPACK compressed
Encryption optional browsers require TLSFor a page with 60 small files, HTTP/1.1 needed tricks: bundling JavaScript and CSS into big files, image sprites, and spreading assets across several domains (domain sharding). With HTTP/2 these tricks matter less and sharding can hurt, since each domain needs its own connection.
Methods, status codes and URLs are unchanged. Only the transport format differs, so your application code does not change.
What to say in the interview
"HTTP/2 keeps the same semantics but changes the wire format: binary framing, multiplexing over one connection, and header compression. It removes HTTP-level head-of-line blocking, though TCP-level blocking remains, which HTTP/3 addresses."
Common mistakes
- Saying HTTP/2 needs changes to your API design.