Free auditStart free
GlossaryGlossary · Performance

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.

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 withChatGPTClaudePerplexityGoogleAI Mode
01Explained

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.

02Check 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
04At 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 compress automatically.

05How 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.

01What 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.

02Is gzip lossless or lossy?

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

03Does 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.

04Should 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. 01RFC 1952: GZIP file format specification version 4.3rfc-editor.org · checked 2026-10-25
  2. 02MDN: Compression in HTTPdeveloper.mozilla.org · checked 2026-10-25
  3. 03MDN: Content-Encoding headerdeveloper.mozilla.org · checked 2026-10-25
  4. 04web.dev: Reduce network payloads using text compressionweb.dev · checked 2026-10-25
Free · 2 minutes

Know the term. Now check your site.

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

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • +212% organic clicks in 90 days Ledgerly