Skip to main content

What is HTTP/2?

1. What HTTP/2 is

HTTP/2 is the second major version of the HTTP protocol, developed by the IETF and released in 2015.

It was created to:

  • increase the speed at which web pages load,
  • reduce latency,
  • cut down the number of TCP connections,
  • and make the protocol more efficient overall.

Put simply: HTTP/2 = the same HTTP, but "packaged" more cleverly. The semantics (GET, POST, headers, status codes) stayed the same, but the data-transfer format and the connection's structure changed radically.

2. Why HTTP/1.1 started to slow down

HTTP/1.1 (1997) had a number of problems:

  • A limitation: 1 request = 1 response. To load 50 resources (images, scripts, CSS), the browser has to open dozens of connections.
  • Head-of-Line Blocking, if one request in the queue stalls, the rest have to wait.
  • Huge headers (cookies, user-agent, etc.) get sent again with every request.
  • No multiplexing: each connection serves only one stream.
  • To speed up a site, developers had to "hack" the protocol, minifying CSS, bundling JS, using CDN domains.

3. What changed in HTTP/2

1. Multiplexing

Now several requests and responses can travel over a single TCP connection at the same time. There are no more "queues" or blocking.

In HTTP/1.1:

javascript
Request 1 → response 1 Request 2 → response 2

In HTTP/2:

javascript
Requests 1, 2, 3in parallel Responses 1, 2, 3in any order

This removes Head-of-Line Blocking at the HTTP level (though not at the TCP level).

2. Binary framing

HTTP/2 sends data as binary frames, rather than as text like HTTP/1.1.

  • It parses faster and is more compact.
  • It removes the ambiguities of a text format.
  • It splits the stream into independent frames and streams.

3. Header compression (HPACK)

Headers (User-Agent, Cookie, Accept-Language, etc.) repeat often. HTTP/2 encodes them using a table and Huffman compression, shrinking the amount of metadata sent.

For example, 1 KB of headers in HTTP/1.1 might take up only ~100 bytes in HTTP/2.

4. Server Push

The server can send the client extra resources before they're even requested.

For example:

javascript
ClientGET /index.html Server/index.html + /style.css + /script.js

That way the browser gets everything it needs right away, with no extra requests. (though in HTTP/3 this feature is gradually leaving the standard.)

5. HTTPS, effectively mandatory

Although HTTP/2 can theoretically be used without TLS, every browser requires HTTPS only for HTTP/2 connections. Encryption has become the standard.

4. What this looks like visually

javascript
HTTP/1.1: HTTP/2: ─────────── ──────────────── Req1Resp1 Stream1: Req1/Resp1 Req2Resp2 Stream2: Req2/Resp2 Req3Resp3 Stream3: Req3/Resp3 (one at a time) (all over one connection)

5. A performance-difference example

HTTP/1.1: the browser opens up to 6 TCP connections per domain, each with its own request queue.

HTTP/2: one connection serves dozens of parallel streams. → less overhead, less latency, fewer handshakes.

The result:

  • pages load faster;
  • less load on the server and the network;
  • more benefit from HTTPS (TLS is used more efficiently).

6. Support

HTTP/2 is supported by:

  • all modern browsers;
  • most servers (Nginx, Apache, Node.js, Caddy, Cloudflare, etc.);
  • Node.js since v8.4 (import http2 from 'node:http2').

7. An example in Node.js

javascript
import http2 from 'node:http2'; import fs from 'node:fs'; const server = http2.createSecureServer({ key: fs.readFileSync('key.pem'), cert: fs.readFileSync('cert.pem'), }); server.on('stream', (stream, headers) => { stream.respond({ 'content-type': 'text/plain', ':status': 200 }); stream.end('Hello from HTTP/2'); }); server.listen(8443);

8. Key differences in a table

CharacteristicHTTP/1.1HTTP/2
FormatTextBinary
Number of connections1 request = 1 connectionOne connection, many streams
MultiplexingNoYes
Header compressionNoHPACK
Server PushNoYes
Stream prioritizationNoYes
HTTPS requiredNoEffectively yes
SpeedSlowerFaster (by 20-40%)

9. In a nutshell

HTTP/2 is a "smarter" HTTP that transmits data as binary, multiplexes streams, and minimizes overhead, making sites noticeably faster with no change to application logic.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.