# Gzip compression

> Gzip compresses text files such as HTML, CSS and JavaScript before a server sends them. See how it is negotiated, how to test it, and when Brotli is better.

Canonical: https://scaplet.com/glossary/gzip-compression

Glossary Glossary · Performance

Gzip compresses text files such as HTML, CSS and JavaScript before a server sends them. See how it is negotiated, how to test it, and when Brotli is better.

3 min

read

4

sources

Oct 24, 2026

updated

Scaplet Editorial Team

author

In one line

Gzip compression is a lossless format that shrinks files so a server sends fewer bytes and the browser unpacks them on arrival. Browsers ask for it in the Accept-Encoding header and servers confirm it with Content-Encoding: gzip. It works best on text such as HTML, CSS and JavaScript, and does little for images.

30-second check

## Is this costing your site traffic?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fgzip-compression%20(%22Gzip%20compression%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fgzip-compression%20(%22Gzip%20compression%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fgzip-compression%20(%22Gzip%20compression%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fgzip-compression%20(%22Gzip%20compression%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 5 parts, 3 minutes.

1. [What gzip compression is 01](#what-gzip-compression-is)
2. [How the browser and server agree on it 02](#how-the-browser-and-server-agree-on-it)
3. [What to compress 03](#what-to-compress)
4. [Gzip vs Brotli 04](#gzip-vs-brotli)
5. [Check it in 2 minutes 05](#check-it-in-2-minutes)

_01_Explained

## What gzip compression is

Gzip is both a file format and the way most web servers compress responses. RFC 1952 defines it as "a lossless compressed data format that is compatible with the widely used GZIP utility," with a cyclic redundancy check to detect corruption. The RFC says the format presently uses the DEFLATE method of compression. MDN says web developers don't need to implement compression themselves, because both browsers and servers already have it.

Because it is lossless, nothing changes in the content. A smaller transfer means the page can start loading sooner, which supports [page speed](/glossary/page-speed).

_02_Check it

## How the browser and server agree on it

MDN describes the exchange as proactive content negotiation. The browser sends an `Accept-Encoding` header listing what it supports. The server picks one, compresses the body and names it in `Content-Encoding`. MDN says the server must also send a `Vary` header containing at least `Accept-Encoding`, so caches can store each version.

MDN also notes that whether a server compresses depends on its configuration and capabilities, so a request that asks for gzip is no guarantee you get it.

A gzip exchange

```
GET /doc HTTP/1.1 Accept-Encoding: gzip, br HTTP/1.1 200 OK Content-Encoding: gzip Vary: Accept-Encoding
```

_03_At a glance

## What to compress

Content

### HTML, CSS, JavaScript

Compress with gzip?

Yes

Why

web.dev says these text assets are where gzip and [Brotli](/glossary/brotli-compression) perform best

Content

### JSON, SVG and other text

Compress with gzip?

Usually yes

Why

They are text. Test on your own responses

Content

### JPEG, PNG, [WebP](/glossary/webp), video, ZIP

Compress with gzip?

No

Why

They are already compressed. MDN says compressing them again can increase the file size

web.dev reports that both algorithms often reach compression rates as high as 70-90% for larger text files. Savings on images are "little to no improvement." For images, use [image compression](/glossary/image-compression) instead.

_04_At a glance

## Gzip vs Brotli

web.dev says gzip and Brotli are the two common algorithms and that all modern browsers support both. Its advice: "Wherever possible, prefer Brotli over gzip." Gzip is still the safe baseline, and MDN calls it "the most common one."

### Compression levels

gzip

1 to 9, with 9 the best

Brotli

0 to 11, with 11 the best

### `Content-Encoding` value

gzip

`gzip`

Brotli

`br`

### Trade-off

gzip

Higher levels take more time

Brotli

Higher levels take more time

For responses compressed on the fly, web.dev says settings in the middle of the range tend to give the best trade-off. For static files, you can compress ahead of time at the highest setting. Many [CDNs](/glossary/cdn) compress automatically.

_05_How it works

## Check it in 2 minutes

1. 1

### Run it on your HTML and on a CSS or JS file

A `content-encoding: gzip` or `br` line means the response was compressed. No line means it was sent as is.
2. 2

### Look at the Vary header

It should include `Accept-Encoding`.
3. 3

### Fix the server if needed

MDN names Apache's `mod_deflate`, Nginx's `ngx_http_gzip_module` and IIS's `<httpCompression>` element as the places to configure it. web.dev says it is the hosting provider's responsibility to configure the server to serve the compressed resource when requested.

See which encoding a URL returns

```
curl -sI -H "Accept-Encoding: gzip" https://example.com/ | grep -i -E "content-encoding|vary"
```

Questions

## Asked a lot.

4 questions people ask next, answered from the sources on this page.

_01_ What is gzip compression?

A lossless compression format, defined in RFC 1952, which says it presently uses the DEFLATE method. Servers use it to shrink text responses and browsers decompress them.

_02_ Is gzip lossless or lossy?

Lossless. RFC 1952 defines a lossless compressed data format, so the decompressed file matches the original.

_03_ Does gzip compression improve SEO?

It makes pages lighter to transfer, which supports page speed. Neither source here makes a ranking claim, so treat it as a performance fix.

_04_ Should I use gzip or Brotli?

web.dev recommends Brotli wherever possible. Gzip remains widely supported and works as a fallback.

Sources · 4

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- rfc-editor.org
- mozilla.org
- web.dev

1. 01 [RFC 1952: GZIP file format specification version 4.3](https://www.rfc-editor.org/rfc/rfc1952) rfc-editor.org · checked 2026-10-25
2. 02 [MDN: Compression in HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Compression) developer.mozilla.org · checked 2026-10-25
3. 03 [MDN: Content-Encoding header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Encoding) developer.mozilla.org · checked 2026-10-25
4. 04 [web.dev: Reduce network payloads using text compression](https://web.dev/articles/reduce-network-payloads-using-text-compression) web.dev · checked 2026-10-25

## Keep learning

[All glossary](/glossary)

[Learn CDN Performance](/glossary/cdn) [Related Page speed Performance](/glossary/page-speed) [Read next Brotli compression Performance](/glossary/brotli-compression) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in glossary
[GTIN](/glossary/gtin) [Guest posting](/glossary/guest-posting) [H1 tag](/glossary/h1-tag) [Head terms](/glossary/head-terms)

More in Performance
[Core Web Vitals](/glossary/core-web-vitals) [Core Web Vitals report](/glossary/core-web-vitals-report) [CORS](/glossary/cors) [Critical CSS](/glossary/critical-css) [Critical rendering path](/glossary/critical-rendering-path) [Cumulative Layout Shift (CLS)](/glossary/cumulative-layout-shift) [dns-prefetch](/glossary/dns-prefetch) [Edge caching](/glossary/edge-caching) [fetchpriority](/glossary/fetchpriority) [First Contentful Paint](/glossary/first-contentful-paint) [First Input Delay (FID)](/glossary/first-input-delay) [font-display](/glossary/font-display) [Gzip compression](/glossary/gzip-compression) [HTTP caching](/glossary/http-caching) [HTTP/2](/glossary/http-2) [HTTP/3](/glossary/http-3) [Image compression](/glossary/image-compression) [Interaction to Next Paint (INP)](/glossary/interaction-to-next-paint) [Largest Contentful Paint](/glossary/largest-contentful-paint) [Lazy loading](/glossary/lazy-loading) [Lighthouse](/glossary/lighthouse) [Page experience](/glossary/page-experience) [Page speed](/glossary/page-speed) [PageSpeed Insights](/glossary/pagespeed-insights)

Terms on this page
[Page speed](/glossary/page-speed) [Brotli compression](/glossary/brotli-compression) [WebP](/glossary/webp) [Image compression](/glossary/image-compression) [CDN](/glossary/cdn)

Free · 2 minutes

## Know the term. _Now check your site._

The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **+212%** organic clicks in 90 days Ledgerly
