HTTP/2 Header Compression with HPACK
You'll learn how HTTP/2 uses HPACK compression to drastically reduce the overhead of request and response headers.
The Problem with Repetitive Headers
In HTTP/1.1, every request and response sends full headers as plain text. When you make dozens of requests to the same site, you're sending nearly identical headers over and over: User-Agent, Accept, Cookie, Host, and so on. This repetition wastes bandwidth—imagine photocopying the same document header on every page instead of just writing "same as before."
How HPACK Works
HPACK is the header compression algorithm built into HTTP/2. It solves header redundancy in two ways:
-
Static Table: A predefined dictionary of common header names and values (like
:method: GET) that both browser and server know. Instead of sending the full text, they just reference an index number. -
Dynamic Table: A session-specific table that remembers headers you've sent before. If you send
Cookie: sessionid=abc123once, subsequent requests can just say "same cookie as before" using an index reference.
Headers are also encoded with Huffman compression, shrinking the bytes needed for any text that must be sent literally.
The Performance Impact
HPACK can reduce header overhead by 70-90% on typical websites with authenticated users and tracking cookies. Since multiplexed HTTP/2 connections send many requests rapidly, this compression becomes even more valuable—less data per request means faster page loads, especially on mobile networks.
Unlike body compression (gzip/Brotli), HPACK is mandatory and automatic in HTTP/2—no configuration needed.
Key Takeaway: HPACK eliminates header redundancy in HTTP/2 by using static and dynamic lookup tables plus Huffman encoding, dramatically reducing bandwidth waste from repetitive headers across multiplexed requests.