Back to the Catalog
compression
http
performance
encoding
networking

Compression: What Actually Shrinks

34 questions

Compression is the cheapest performance win on the web and the one most often applied to the wrong bytes. This Quiz covers what makes data compressible, how Huffman and LZ77 actually work, why Brotli beats gzip on text, and why base64 inlining costs you a third of the file.

Questions

  1. Not answered. What property does a compression algorithm actually exploit to shrink data?
  2. Not answered. Why does gzipping an already-.gz-compressed file usually make it slightly bigger, not smaller?
  3. Not answered. The pigeonhole principle applied to lossless compression
  4. Not answered. You need to both gzip and encrypt a payload before sending it. In which order should you apply them?
  5. Not answered. What should actually decide whether you export an image as lossless or lossy?
  6. Not answered. Given these symbol frequencies out of 100 total occurrences, which symbol gets the shortest Huffman codeword?
  7. Not answered. What is the minimum possible total length, in bits, of a 100-symbol message with these frequencies under an optimal Huffman code?
  8. Not answered. Why must every Huffman codeword be "prefix-free" (no codeword may be a prefix of another)?
  9. Not answered. What goes wrong when a code isn't prefix-free?
  10. Not answered. A symbol occurs 99% of the time. Why can't Huffman coding get its average cost below 1 bit per occurrence, and what technique can?
  11. Not answered. Static versus dynamic Huffman tables
  12. Not answered. LZ77 replaces a repeated run of bytes with a back-reference. What do the two numbers in a (distance, length) pair mean?
  13. Not answered. An LZ77-based compressor uses a 32 KiB sliding window. What is the maximum distance, in bytes, that a back-reference in this compressor can point backward?
  14. Not answered. Encoding abcabcabcabc by hand: how many back-reference tokens are needed?
  15. Not answered. DEFLATE runs LZ77 first, then Huffman coding. Which kind of redundancy does each stage catch?
  16. Not answered. gzip, zlib, and "raw deflate" all compress with the same DEFLATE algorithm. Select every correct statement about how they differ.
  17. Not answered. Choosing a gzip compression level: level 6 versus level 9
  18. Not answered. Brotli ships with a large built-in static dictionary of common web text. Why does this make it beat gzip specifically on small HTML/CSS/JS files?
  19. Not answered. Why does Brotli's edge over gzip shrink on a large, unique payload — say, a big proprietary binary blob?
  20. Not answered. Brotli quality levels and when to use the highest one
  21. Not answered. Where does zstd typically sit on the speed/ratio curve relative to gzip and Brotli/xz?
  22. Not answered. A company serves thousands of small, similarly-shaped JSON API responses and trains a custom shared compression dictionary on its own past traffic. What's the underlying idea?
  23. Not answered. A browser sends Accept-Encoding: gzip, br and gets back a response with Content-Encoding: br. What did each header do?
  24. Not answered. How does Transfer-Encoding differ from Content-Encoding?
  25. Not answered. A server returns different bodies for the same URL depending on Accept-Encoding, but omits Vary: Accept-Encoding. What can go wrong?
  26. Not answered. For which of these does applying gzip/Brotli on top wastes CPU for close to 0% additional savings?
  27. Not answered. Why do most servers skip compressing very small responses, such as under roughly 1 KB?
  28. Not answered. A response mixes a secret token with attacker-controlled input, and the response is compressed before being sent over HTTPS. What does the compressed length leak?
  29. Not answered. What's the standard mitigation for BREACH/CRIME-style compression length attacks?
  30. Not answered. A binary asset is exactly 300,000 bytes. Approximately how many bytes will its base64-encoded text form be, ignoring the small fixed padding?
  31. Not answered. When does inlining an image as a base64 data URI actually help performance, and when does it hurt?
  32. Not answered. A CSS file embeds a large image as a base64 data: URI inside a background-image rule. What's a downside specific to putting it in CSS rather than in HTML?
  33. Not answered. Minifying a JS file before gzipping it, versus gzipping the original unminified file: how does minification's raw-size saving compare to its saving after gzip?
  34. Not answered. Why does gzipping 200 small JSON files after concatenating them into one file beat gzipping each file separately?