Enable Gzip Compression for Faster HTML (Test and Fix Guide)
Turn on gzip so your server sends HTML, CSS and JavaScript in far fewer bytes, then confirm it with a header check and our free report.
Free to use 14 min read Updated Oct 2026
Enable Gzip Compression: The Quick Answer
Quick answer: To enable gzip compression, you tell your server to shrink HTML, CSS, JavaScript and other text before it goes out, and the browser unpacks it on arrival, so the same page downloads in far fewer bytes. Our report wants the main HTML document to come back with a Content-Encoding header of gzip. On our own home page that took the HTML from 143,077 bytes to 27,851, about 81 percent smaller.
- Pass: the HTML document arrives with Content-Encoding set to gzip.
- Fail: the header is missing, or it names another coding such as br, zstd or deflate.
- Fix: switch gzip on in the server, the host panel or the CDN, then test again.
What Gzip Compression Does to Your HTML
Gzip is a compression format that wraps the DEFLATE method (RFC 1951) inside a small container (RFC 1952). Text compression works because markup repeats itself constantly, and zlib, the library behind most implementations, does the heavy lifting. Tag names, class names, keywords and runs of indentation get swapped for short back references, and the browser reverses the swap without losing a single character.
The two sides settle on a coding through content negotiation. The browser sends an Accept-Encoding request header, one of the request headers every page load carries, listing the codings it can unpack. The server picks one, compresses the body and answers with a Content-Encoding header naming its choice. The rules for this exchange live in RFC 9110, and the MDN guide to HTTP compression explains the flow with examples.
Compressed responses should also carry Vary: Accept-Encoding. That header tells shared caches, including a CDN, to keep one copy per coding so a client that cannot read gzip never receives a gzipped body. Apache adds it for you in the normal case, while Nginx needs gzip_vary on.
Gzip belongs on text types: HTML, CSS, JavaScript, JSON, SVG and XML. Images, video, PDF files and WOFF2 fonts are already compressed, so running gzip over them burns CPU and saves almost nothing.
Minification is a different job. It edits the file at build time by removing whitespace and comments, while gzip works on the wire, so the two stack. Run your markup through the free HTML Minifier first and let the server compress the result. Brotli (RFC 7932) and Zstandard (RFC 8878) are newer codings that do the same wire job, and a later section compares them with gzip.
Why Enabling Gzip Compression Matters for Speed and SEO
We measured real files rather than quoting a generic percentage. The gzip figures use level 6, and the last row shows minifying first and compressing second.
| File | Plain bytes | Gzipped bytes | Smaller by |
|---|---|---|---|
| Our home page HTML | 143,077 | 27,851 | about 81 percent |
| jQuery 3.7.1, original | 285,314 | 84,055 | about 71 percent |
| jQuery 3.7.1, minified | 87,533 | 30,413 | about 65 percent |
| Original versus minified plus gzipped | 285,314 | 30,413 | about 89 percent |
Smaller HTML saves bandwidth for you and arrives sooner for every visitor, so the browser discovers your stylesheets, scripts and images sooner and can start fetching them sooner. That helps First Contentful Paint and Largest Contentful Paint, and it saves mobile data for visitors on slow connections. Total weight is a wider topic that our page size guide covers, so this page sticks to the transfer saving.
Compression is not a ranking signal by itself. It helps indirectly, through faster loading, and the background is in our write-up on page speed and SEO. Crawlers are not a concern either: Google Search Central documents gzip, deflate and Brotli as encodings Googlebot accepts, so compressed pages are safe to crawl.
One more reference point: Lighthouse and PageSpeed Insights flag text responses that arrive uncompressed (the classic audit skipped anything under about 1.4 KiB or with savings under 10 percent). Our row has no such thresholds, which the next section spells out.
How SEO Site Checker Tests Gzip Compression
The check is narrow. It looks at one header on one response and answers Passed or Failed, with no Warning state.
The exact rule: our report reads the Content-Encoding header of the main HTML document, lowercases it and compares it with the single value gzip. Equal means Passed. Anything else means Failed.
| Content-Encoding value | Row in the report | What it usually means |
|---|---|---|
| gzip | Passed | The server compressed the HTML with gzip. |
| br | Failed | The page is compressed with Brotli, which this row does not currently accept. |
| zstd | Failed | The page is compressed with Zstandard, also not accepted today. |
| deflate or x-gzip | Failed | A rare coding, or an old alias for gzip. |
| No header at all | Failed | The HTML went out at full size. |
| Firewall block or error page | Depends on that page | The scanner judges whatever page it was served, so a block page that arrives gzipped can show Passed and one that does not shows Failed. This is a reason to doubt the row, not your compression. |
A Failed row is a request for a closer look, not a verdict on your hosting. The red How to Fix button opens the short steps that also appear lower on this page, and a Passed row adds one to the passed total in the report summary.
What the report reads
Our scanner opens your URL in headless Chromium, waits for the page to finish loading and takes the response for the main document, after any redirects. From that response it reads the Content-Encoding header, lowercases the value and compares it with gzip. Nothing else about the response is judged, and no before and after size comparison is made.
What Passed and Failed mean
Passed means the header says gzip, in any letter case. Failed means the header is absent or names a different coding. The savings percentage that appears in the Failed message is a typical estimate, not a measurement of your page. Our own tests gave about 81 percent for the home page HTML and about 71 percent for unminified jQuery, so the real number depends entirely on your markup.
Why a compressed site can still show Failed
Chromium advertises gzip, deflate, br and zstd when it talks to an HTTPS site. Servers and CDNs that prefer Brotli or Zstandard will answer with br or zstd, and our row reads both as not gzip. In our own spot check of 25 well known sites, 8 of the 20 that loaded a normal page answered with br.
So if DevTools or curl shows br or zstd, your compression is working and the red row is a limit of this check. Do not downgrade a healthy Brotli setup just to turn the row green. The check steps below show how to read the header yourself.
What this check leaves out
Only the HTML document is examined, so CSS, JavaScript, JSON and SVG files can be uncompressed while the row still says Passed. Compression level, the Vary header and BREACH exposure are not tested either, and the check steps below show how to read the Vary header and the level by hand.
How to Check If Gzip Compression Is Enabled
Two checks need no extra tools, and the free report gives you a third. Run one of them before you change anything.
- Use Chrome DevTools. Open the Chrome DevTools Network tab, reload the page and click the first request, which is the HTML document. Under Response Headers look for content-encoding, and compare the two numbers in the Size column, where the transferred size should be well below the resource size.
- Use curl. Send a request with an Accept-Encoding header that advertises gzip and print only the response headers, using the first command below. Then run the second command, which advertises br, to see whether Brotli is switched on as well.
- Read the answer. A content-encoding of gzip means compression is on. A value of br or zstd means it is on with another coding, and no header means it is off or the file type is missing from the compress list. Because the first command only advertises gzip, it will show gzip or nothing, never br.
- Look for the Vary header. The same response should include vary: accept-encoding, so caches store a separate copy for each coding.
- Run the free report. Our scanner shows the row exactly as it sees your page, which helps when a CDN or firewall treats it differently from your browser.
curl -s -o /dev/null -D - -H "Accept-Encoding: gzip" https://example.com/In the output, find the line content-encoding: gzip. Header names are case-insensitive, and the capitalization depends on the HTTP version: HTTP/2 and HTTP/3 always show lowercase names, while an HTTP/1.1 server usually sends Content-Encoding with capitals. If the response shows only a status line and a few ordinary headers, the server is sending the page at full size.
curl -s -o /dev/null -D - -H "Accept-Encoding: br" https://example.com/A content-encoding: br line here means Brotli is already on, which is a healthy result.
How to Enable Gzip Compression on Apache and Nginx
The rule is the same on both servers. Compress text types only, keep the configuration in one place, reload the server and test again. The same files also control HTTP/2, which our HTTP/2 setup guide covers without repeating this page.
Enable gzip on Apache with mod_deflate
First confirm that mod_deflate is loaded. On Debian family systems, a2enmod deflate followed by a reload does it. Then put the block below in the virtual host, or use the .htaccess gzip route if you have no access to the main config, and keep the file type list short. Apache's own Apache mod_deflate documentation lists every directive and the notes on Vary and BREACH.
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE text/javascript application/javascript
AddOutputFilterByType DEFLATE application/json application/xml image/svg+xml
</IfModule>The module is called mod_deflate, yet the header it sends says gzip. That mismatch catches people out, because they look for the word deflate in the response and conclude the filter is not working.
Enable gzip on Nginx
Place the directives in the http block, or in a server block if you only want them for one site. The Nginx gzip module reference documents each one and its default.
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_vary on;
gzip_proxied any;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml image/svg+xml;Nginx compresses text/html on its own once gzip is on, so you do not list it. By default gzip is off, the level is 1 and the minimum length is 20 bytes. Each line does one job:
- gzip on turns the module on for the chosen context.
- gzip_comp_level 5 picks a middle compression level that balances size and CPU.
- gzip_min_length 256 skips tiny responses where the gzip wrapper would not pay for itself.
- gzip_vary on adds Vary: Accept-Encoding so shared caches stay correct.
- gzip_proxied any also compresses responses to requests that carry a Via header, which is how a proxy or CDN in front of your server identifies itself.
- gzip_types lists the extra MIME types to compress beyond HTML.
Choose a sensible compression level
We gzipped jQuery 3.7.1 at three levels. Level 1 produced about 102 KB, level 6 about 84 KB and level 9 about 83.6 KB, rounded because gzip builds differ by under one percent. Levels 5 and 6 capture almost all of the gain, while the jump to 9 saves only a few hundred bytes and costs noticeably more CPU.
Reload and test again
Check the syntax with nginx -t or apachectl configtest, reload the server, then run the curl command again and read the content-encoding line.
Enable Gzip Compression in WordPress, cPanel and Other Platforms
Many hosts already compress, so read the header before touching anything. If it is missing, find your platform in the table. Behind a CDN, remember that compression can happen at the edge, a topic our CDN usage test page owns.
| Platform | Where to look | What to do |
|---|---|---|
| WordPress | Host panel, .htaccess or a caching plugin | On Apache hosting, paste the Apache block into .htaccess above the WordPress rules, or tick the gzip option in a caching plugin such as W3 Total Cache (Browser Cache settings). On Nginx hosting the rules live in the server config, so ask the host. |
| cPanel | Optimize Website screen | Choose Compress All Content, or pick specific MIME types. cPanel applies the Apache compression settings for you, so you do not need to write the rules by hand. |
| IIS | Compression feature in IIS Manager | Turn on static and dynamic content compression. If the dynamic option is greyed out, install the Dynamic Content Compression role service first. |
| LiteSpeed | Server or host settings | LiteSpeed supports gzip and Brotli compression in its server or virtual host settings, and many hosts enable it already. Read the header first, and ask the host if it is missing. |
| Shopify, Wix, Squarespace | No setting offered | The platform handles it. If the report shows Failed, read the header first. |
| Cloudflare and other CDNs | Edge settings | Compression is usually automatic, and a br answer here is healthy, so leave it. Make sure only one layer, the origin or the CDN, compresses the response. |
For WordPress gzip compression, test first, then ask the host, then edit .htaccess. A plugin that compresses while the server also compresses is the classic double compression trap, covered below.
Gzip vs Brotli: Which Compression Should You Enable?
Gzip is the universal baseline, Brotli usually makes text smaller and Zstandard is the newest of the three. The browser lists the codings it understands in Accept-Encoding and the server answers with the best one it has, so a server that offers both Brotli and gzip serves each visitor the smaller format their browser accepts.
| Coding | Header value | Where it stands | Our report today |
|---|---|---|---|
| Gzip | gzip | Supported everywhere | Passed |
| Brotli | br | Widely supported over HTTPS | Failed |
| Zstandard | zstd | Newer, supported by recent Chromium builds | Failed |
| Deflate | deflate | Rarely used for web pages | Failed |
Apache has had mod_brotli since version 2.4.26, and it takes the same kind of type list, for example AddOutputFilterByType BROTLI_COMPRESS text/html text/css application/javascript. Nginx open source ships without Brotli, so it needs the third-party ngx_brotli module.
The other route is a CDN, and many switch Brotli on by themselves. Cloudflare compression, for example, is applied at the edge without any change on your origin. Brotli's highest levels cost a lot of CPU, so the usual way to get them is precompression: the server stores a .br or .gz copy next to each static asset and serves it, with no compression bill on every request.
Our advice is to keep gzip as the safe baseline and add Brotli where your stack supports it, because visitors get the smaller file and older clients still get gzip. Today our row accepts gzip only, so a br answer shows Failed even though Brotli is good practice (see the explanation above).
Common Gzip Compression Mistakes to Avoid
Most failed setups come from a short list of slips, so check these before blaming the server.
- Compressing files that are already compressed. JPEG, PNG, WebP, MP4, WOFF2 and ZIP files gain nothing from gzip, so use the Image Compressor to shrink pictures instead.
- Leaving out JSON, SVG or XML. If the type list stops at HTML and CSS, API responses and vector graphics still travel at full size.
- Running level 9 on dynamic pages. The extra CPU buys a handful of bytes and can slow Time to First Byte.
- Skipping Vary: Accept-Encoding. Without it a cache can hand a compressed copy to a client that cannot read it.
Double compression: if both the application and the server compress, or both the origin and the CDN do, the browser can fail with ERR_CONTENT_DECODING_FAILED. Compress in one layer only.
BREACH caution: compressed HTTPS responses that mix a secret token with text an attacker can influence can leak that token. Masking or rotating tokens per request is the usual defence.
How to Fix
The short version, the same steps you see when you click How to Fix in your report.
Why this fails: the main HTML document came back without Content-Encoding gzip, so the page travels at full size, or the server answered with another coding such as br. Our report reads that one header and accepts only the value gzip.
How to fix it:
- Read the header first. Run the curl command below or open the DevTools Network tab. If it shows br or zstd, your page is already compressed. Our report only accepts gzip, so the row stays red, but keep the better setup. If the header is missing, continue.
- On Apache, add the mod_deflate block below to .htaccess or the virtual host. If the module is not loaded, enable it first with a2enmod deflate, then reload Apache. mod_deflate always outputs gzip.
- On Nginx, put the gzip directives in the http or server block, run nginx -t and reload the server.
- On a managed host or cPanel, switch on compression in Optimize Website, or ask the host. If you use a CDN, enable compression there instead.
- Keep the list to text types. Leave images, video and fonts out.
Apache, .htaccess or virtual host:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE text/javascript application/javascript
AddOutputFilterByType DEFLATE application/json application/xml image/svg+xml
</IfModule>Nginx, http or server block:
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_vary on;
gzip_proxied any;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml image/svg+xml;Check the header:
curl -s -o /dev/null -D - -H "Accept-Encoding: gzip" https://example.com/Platform shortcuts:
- WordPress: on Apache, use the Apache block above or a caching plugin option. On LiteSpeed or Nginx, ask the host.
- Shopify, Wix, Squarespace: the platform usually compresses for you, so there is nothing to set.
- Cloudflare: compression is automatic, so avoid compressing twice.
Re-test: run the curl command again and look for content-encoding: gzip, then run our free SEO report again and look for Passed on HTML Compression/GZIP.
Frequently Asked Questions
How do I enable gzip compression on my website?
How do I check if gzip compression is enabled?
What is the difference between gzip and Brotli compression?
Why does a test say gzip compression is disabled when my site loads fast?
Is gzip compression worth using for SEO and speed?
Which file types should I compress with gzip?
What gzip compression level should I use?
How does gzip compression work?
See how your site scores right now
Paste your address into the free report, then use the How to Fix button on anything that needs work.
Free to use. Results in under a minute for most sites.