← Lessons

quiz vs the machine

Platinum1820

Networking

The Compression on the Wire

Trading processor time for fewer bytes to send.

6 min read · advanced · beat Platinum to climb

Fewer Bytes, More Work

Compression shrinks data before it crosses the network, so fewer bytes travel. It trades extra processor work at both ends for reduced transfer size and time, which often pays off on slow or distant links.

Where It Applies

Compression appears at several layers.

  • Payload compression shrinks response bodies such as text and scripts before sending.
  • Header compression removes repeated request fields that would otherwise repeat on every request.
  • Streaming compression lets a sender compress as it produces data rather than buffering it all.

Already compressed media such as images and video gains little, so re compressing it wastes work.

A Security Caution

Mixing compression with secrets can leak data. If an attacker can influence part of a compressed and encrypted message, the change in compressed size can reveal a secret, an attack class behind several named exploits. The fix is to avoid compressing sensitive fields together with attacker controlled input.

Key idea

Compression trades processor time for fewer bytes across payloads and headers, helps most on slow links and uncompressed data, and must avoid mixing secrets with attacker controlled input to prevent size based leaks.

Check yourself

Answer to earn rating on the learn ladder.

1. What core tradeoff does on the wire compression make?

2. Why does compressing images and video usually gain little?

3. What is the security caution when combining compression and encryption?