HTML, CSS, JavaScript
- Compress with gzip?
- Yes
- Why
- web.dev says these text assets are where gzip and Brotli perform best
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.
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.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
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.
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.
GET /doc HTTP/1.1
Accept-Encoding: gzip, br
HTTP/1.1 200 OK
Content-Encoding: gzip
Vary: Accept-Encodingweb.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 instead.
Content-Encoding valuegzipbrFor 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.
A content-encoding: gzip or br line means the response was compressed. No line means it was sent as is.
It should include Accept-Encoding.
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.
curl -sI -H "Accept-Encoding: gzip" https://example.com/ | grep -i -E "content-encoding|vary"4 questions people ask next, answered from the sources on this page.
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.
Lossless. RFC 1952 defines a lossless compressed data format, so the decompressed file matches the original.
It makes pages lighter to transfer, which supports page speed. Neither source here makes a ranking claim, so treat it as a performance fix.
web.dev recommends Brotli wherever possible. Gzip remains widely supported and works as a fallback.
The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.