Glossary

Gzip Compression

Definition: Gzip is a file compression algorithm used by web servers to reduce the size of HTML, CSS and JavaScript files before sending them to the browser.

Gzip is a lossless data compression algorithm (GNU zip) that web servers use to compress response bodies before transmitting them over the network. The browser decompresses the data before rendering it. For text-based files — HTML, CSS, JavaScript, JSON, XML — Gzip typically reduces file size by 60–90%.

How Gzip Works in HTTP

  1. The browser sends a request with the header: Accept-Encoding: gzip, deflate, br
  2. The server compresses the response and replies with: Content-Encoding: gzip
  3. The browser decompresses the response and renders it normally.

Gzip vs Brotli

  • Gzip — Universal support, very fast compression/decompression. The standard choice.
  • Brotli — Developed by Google. Compresses 15–25% better than Gzip for web assets. Supported by all modern browsers. Use Brotli when available, Gzip as fallback.

Enabling Gzip on Common Servers

  • Nginxgzip on; in nginx.conf.
  • Apache — Enable mod_deflate.
  • IIS — Enable Dynamic / Static Compression in site settings.
  • ASP.NET Core — Add app.UseResponseCompression().