---
title: "Gzip"
description: "Gzip is a data compression method for HTTP that shrinks file size and speeds up pages. Learn how it works and how to enable it in your server config."
url: "https://nodea.io/en/glossary/gzip"
lang: "en"
updated: "2026-07-13"
---

# Gzip

> Gzip is a widely used lossless data compression method for shrinking the size of files sent between a server and a browser, cutting page load time and saving bandwidth.

**Gzip** is a widely used lossless data compression method, employed on the web mainly to shrink the size of files sent between a server and the user's browser. When a browser requests a page, the server can compress text files on the fly — [HTML](https://nodea.io/en/glossary/html), [CSS](https://nodea.io/en/glossary/css) and [JavaScript](https://nodea.io/en/glossary/javascript) — before sending them over the wire. The result is often several times less data transferred and a noticeably faster site, which is why enabling Gzip is a fundamental step in performance [optimization](https://nodea.io/en/glossary/optimization).

## How Gzip works

The mechanism relies on negotiation between client and server within the [HTTP](https://nodea.io/en/glossary/http) protocol:

1. The browser signals with an *Accept-Encoding: gzip* header that it accepts compressed content.
2. The server compresses the response using the DEFLATE algorithm (combining LZ77 and Huffman coding) and adds a *Content-Encoding: gzip* header.
3. The browser receives the smaller payload and decompresses it on its side before rendering the page.

Compression is especially effective for text files with repeating patterns (tags, property names, keywords). There is no point compressing already-compressed formats like JPEG, PNG or MP4 — the gain would be negligible while wasting CPU.

## Gzip in practice

Gzip is enabled in the web server configuration:

- **Apache** — via the *mod\_deflate* module, often configured in the [.htaccess](https://nodea.io/en/glossary/htaccess) file.
- **Nginx** — with the *gzip on* and *gzip\_types* directives specifying which file types to compress.
- **CDN and cache** — content delivery networks usually compress responses automatically.

A good practice is to combine Gzip (or the more modern [Brotli](https://nodea.io/en/glossary/brotli)) with [Cache-Control](https://nodea.io/en/glossary/cache-control) headers, so you shrink transfer size and reduce the number of downloads at once. A correct configuration is easy to verify in the browser's developer tools by checking for the Content-Encoding header.

### How is Gzip different from Brotli?

Both are lossless compression algorithms for HTTP traffic. Brotli, developed by Google, usually offers a slightly better compression ratio for text files at comparable performance, so it is often the first choice for modern sites. Gzip, however, remains a universal standard supported almost everywhere and an excellent fallback.

## Related

- [Brotli](https://nodea.io/en/glossary/brotli)
- [Optimization](https://nodea.io/en/glossary/optimization)
- [Cache-Control](https://nodea.io/en/glossary/cache-control)
- [Apache](https://nodea.io/en/glossary/apache)
- [Nginx](https://nodea.io/en/glossary/nginx)

---

Languages: [pl](https://nodea.pl/pl/slownik-pojec/gzip.md)  
Site index: [llms.txt](https://nodea.io/en/llms.txt)
