What Is Gzip Compression?
Gzip compression is a way of shrinking text-based files such as HTML, CSS, JavaScript, JSON and SVG on the server before they are sent to the browser, which then decompresses them automatically. It uses the DEFLATE algorithm and often reduces text files by 60 to 80 percent, cutting download time without changing the content. Every modern browser supports it, and Brotli is its more efficient successor.
What Is Gzip Compression?
Gzip is a file format and compression tool created in the early 1990s, which HTTP adopted as a content encoding. Web servers apply it to responses on the fly or serve files that were compressed in advance. Text compresses well because it is full of repetition: the same tags, class names, property names and keywords appear again and again, so a large stylesheet such as Bootstrap's minified CSS becomes dramatically smaller once gzipped. Compression is different from minification. Minification removes whitespace and comments and shortens names in the source, while compression encodes whatever bytes remain; the two work best together. Formats that are already compressed, such as JPEG, PNG, WebP, AVIF, WOFF2 fonts, MP4 video and ZIP files, gain little or nothing from gzip and should be sent as they are.
How Gzip Compression Works
Compression is negotiated through HTTP headers. Every request from a modern browser includes an Accept-Encoding header listing the encodings it understands, for example Accept-Encoding: gzip, deflate, br, zstd. If the server supports one of them and the file type is configured for compression, it compresses the response body and adds Content-Encoding: gzip (or br for Brotli) so the browser knows how to decode it. It should also send Vary: Accept-Encoding, which tells caches and CDNs to store compressed and uncompressed versions separately. Inside the file, DEFLATE works in two steps: LZ77 replaces repeated strings with short references back to an earlier occurrence, and Huffman coding then gives the most frequent symbols the shortest bit codes. Servers offer compression levels from 1 (fastest) to 9 (smallest); higher levels cost more CPU for small extra savings, so dynamic responses often use a middle level, while static files can be compressed once at the maximum level and served from disk, for example with Nginx's gzip_static on. Brotli, developed by Google and supported by all modern browsers over HTTPS, uses the same negotiation and usually produces smaller text files than gzip, and Zstandard (zstd) is now supported by Chromium-based browsers and Firefox as well.
Best Practices for Gzip Compression
Enable compression for every text-based type, not just HTML. In Nginx, gzip on; compresses text/html by default, but you must list the other types, for example gzip_types text/css application/javascript application/json image/svg+xml;, and add gzip_vary on; so the Vary header is sent. In Apache, mod_deflate does the same with AddOutputFilterByType DEFLATE text/html text/css application/javascript. Skip very small responses (a gzip_min_length of around 256 bytes is a reasonable starting point), because the compression overhead can outweigh the saving. Do not compress images, WOFF2 fonts, video or archives. Where your server or CDN supports it, serve Brotli to browsers that accept it and keep gzip as the fallback; many CDNs handle both automatically. After deploying, confirm that compression is working rather than assuming it: run curl -sI -H "Accept-Encoding: gzip" https://example.com/ and look for content-encoding: gzip, or compare the transferred size and resource size columns in the Network panel of Chrome DevTools. Lighthouse also flags uncompressed text files in its "Enable text compression" audit. Finally, if a page combines secrets such as CSRF tokens with text that a user can control, review guidance on the BREACH attack, since compressing such responses over HTTPS can leak information.
Gzip Compression and Canvas Builder
Canvas Builder exports a self-contained package of HTML, CSS, JavaScript, fonts and images, and the text files in it compress very well, so enabling gzip or Brotli on the server that hosts the export is one of the quickest speed gains available. Compression is configured on the web server or CDN rather than in the HTML, so check the response headers once after you deploy.
Start building freeFrequently asked questions
Is gzip still necessary if my site uses Brotli?
Yes, keep it as a fallback. Browsers only advertise Brotli over HTTPS, and some clients, bots and older tools accept gzip but not Brotli. The server picks the best encoding each client supports, so offering both costs visitors nothing.
How much does gzip reduce file size?
For text files the saving is commonly in the range of 60 to 80 percent, depending on how repetitive the content is and the compression level used. Large CSS and JavaScript files usually compress very well. Images and fonts that are already compressed see little or no reduction.
How do I check if gzip is enabled on my website?
Request a page with curl -sI -H "Accept-Encoding: gzip" https://yoursite.com/ and look for a Content-Encoding: gzip or br header in the response. In Chrome DevTools, the Network panel shows a smaller transferred size than resource size for compressed files. PageSpeed Insights also reports uncompressed text resources.
Does gzip compression help SEO?
Indirectly. Compression makes pages download faster, which supports metrics such as Largest Contentful Paint that feed into Google's page experience signals, and it reduces the bandwidth crawlers use. It is not a ranking factor by itself.