Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Gzip or Brotli errors and truncated HTML: how to fix them

SEO-079Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

Compression makes pages smaller for travel. The server adds a header such as Content-Encoding: gzip or Content-Encoding: br (Brotli), and the browser unpacks the page. It goes wrong in a few ways.

Common forms of the problem
  • Double compression: the origin and the CDN or proxy both compress, so the body cannot be unpacked.
  • Wrong header: the body is plain text but the header says gzip, or the reverse.
  • Truncated body: the connection closes early, or Content-Length does not match the bytes sent.
  • Broken Brotli or gzip stream: a PHP error, a timeout or a full disk cuts the stream mid-way.
  • Cache serving a compressed copy to a client that did not ask for compression.

Chrome often reports this as ERR_CONTENT_DECODING_FAILED. A crawler may not show any error. It may simply index a half page or skip it.

Why it costs you leads or sales

If the HTML is cut off, the part that is missing may be the form, the buy button, the footer scripts or the tracking tags. Visitors see a blank or broken page and leave. Search engines and AI crawlers can only read what they receive, so a truncated page can lose its content, links and structured data. The fault is often partial: it may affect only some pages, some browsers, or only requests that ask for Brotli, so it is easy to miss when you test on your own machine.

Where a truncated page breaks the journey
  1. Ad or search clickVisitor or crawler requests the page
  2. HTML deliveredStream is cut off or cannot be decoded
  3. Form and button renderMissing from the partial HTML
  4. Lead or saleNever reached

The HTML is cut off before the form, so later steps never happen.

How to check if your site has it

Request the page the way a browser does and compare what the server says with what it sends. Run these from a terminal, and try your most important pages.

Test gzip and Brotli responsesbash
# See the headers sent with each encoding
curl -sI -H 'Accept-Encoding: gzip' https://example.com/ | grep -i -E 'HTTP|content-encoding|content-length|transfer-encoding'
curl -sI -H 'Accept-Encoding: br' https://example.com/ | grep -i -E 'HTTP|content-encoding|content-length'

# Let curl decode it. Errors here mean the body is broken
curl -s --compressed -o /dev/null -w '%{http_code} %{size_download}\n' https://example.com/

# Check the HTML ends properly
curl -s --compressed https://example.com/ | tail -c 200

# Try with no compression at all
curl -s -H 'Accept-Encoding: identity' https://example.com/ | wc -c
What to look for
  • curl prints errors such as (61) Unrecognized content-encoding or (23) Failed writing body.
  • The page does not end with </html>.
  • The header shows two encodings, for example gzip, gzip.
  • The identity (uncompressed) page works but the gzip or br one does not.
  • Results differ between the CDN address and the origin address.
  • The Network tab in Chrome DevTools shows the request as failed or the response as empty.

How to fix it

Find the layer that breaks the response
  1. Test the origin directly

    Request the server by its own address or with a host override, bypassing the CDN. If it is fine, the CDN or proxy is the cause.

  2. Make only one layer compress

    Pick the origin or the CDN. Turn off the other layer's compression for HTML so the body is not compressed twice.

  3. Clear caches

    Purge the CDN, page cache and any server cache so no broken copy is served.

  4. Check logs for early exits

    Look in the PHP or app error log for fatal errors, memory limits or timeouts that stop output halfway.

  5. Retest with curl

    Repeat the commands above for gzip, br and identity.

Fix by platform
  1. Stop duplicate compression

    If a caching or performance plugin has a GZIP option and your host or CDN already compresses, switch the plugin's option off. Also check for zlib.output_compression enabled in PHP together with another compressor.

  2. Deactivate plugins to isolate

    Deactivate caching and optimisation plugins one at a time and retest with curl. Look for PHP notices or whitespace output before headers in the error log.

  3. Purge caches

    Clear the plugin cache, host cache and CDN cache.

Example: sensible nginx compression for HTMLnginx
gzip on;
gzip_vary on;
gzip_min_length 256;
gzip_types text/html text/css application/javascript application/json image/svg+xml;
# Do not enable this if the upstream or CDN already compresses HTML.

How to confirm it's fixed

Confirmation checks
  • curl with --compressed returns 200 and no decoding error.
  • gzip, br and identity requests all return the same page ending in </html>.
  • Only one Content-Encoding value appears in the headers.
  • Chrome loads the page with no ERR_CONTENT_DECODING_FAILED.
  • Search Console URL Inspection shows the complete HTML.
  • A test form submission and a test purchase journey still work.

How to prevent it happening again

Habits that keep it away
  • Document which layer owns compression and leave the others off.
  • After changing CDN, host, plugin or server config, run the curl tests on your key pages.
  • Keep Vary: Accept-Encoding on compressed responses.
  • Watch error logs for early script exits and memory limit errors.
  • Recheck after platform or PHP version upgrades.
Compression setup

Broken

  • Origin and CDN both compress HTML
  • Header says gzip, body does not decode
  • Pages end mid-tag

Fixed

  • One layer compresses
  • Headers match the body
  • Every page ends with </html>

How FunnelGuard handles this

FunnelGuard does not check for gzip or Brotli errors or truncated HTML yet. It is a possible future check. Today FunnelGuard runs your real customer journeys in a browser on a schedule and checks each step. If a broken response means a form or button never appears, the journey fails, FunnelGuard re-checks from a second region and sends one alert with a screenshot and a likely cause. That tells you the journey broke, but it does not name compression as the reason.

To watch for this directly, run the curl tests above after every change to your hosting, CDN or caching, and use URL Inspection in Google Search Console on key pages. You can also try FunnelGuard free on 1 site with 2 journeys and daily checks, no card needed.

Questions people ask

Why is my page showing ERR_CONTENT_DECODING_FAILED?

The browser could not unpack the page because the Content-Encoding header does not match the body. The usual cause is double compression, where both the server and a CDN or plugin compress the HTML. Turn compression off in one layer and clear caches.

How do I check if my site uses gzip or Brotli?

Run curl -sI -H 'Accept-Encoding: gzip, br' https://yoursite.com/ and look for a Content-Encoding header. Its value will be gzip or br if compression is on. Browser DevTools shows the same header in the Network tab.

Why is my HTML cut off before the closing tag?

The response probably ended early. Typical causes are a PHP fatal error, a memory limit or timeout, a proxy closing the connection, or a Content-Length that does not match the body. Check error logs and test the origin without the CDN.

Can truncated HTML hurt my SEO?

Yes. Search engines and AI crawlers only see what they receive, so missing content, links or structured data may not be indexed. Pages that fail to decode can also be treated as errors and crawled less.

Should I use gzip or Brotli?

Either works for HTML. Brotli usually makes files smaller, and gzip is supported everywhere. What matters most is that only one layer compresses and the headers match the body.

Why does the page work for me but not for Googlebot?

Your browser may be served a cached or differently encoded copy. A crawler may ask for another encoding and hit a broken path. Test with curl using different Accept-Encoding values and use Search Console URL Inspection.

Does FunnelGuard detect gzip or truncated HTML errors?

Not yet. It is a possible future check. FunnelGuard does run your journeys on a schedule, so a broken page that stops a form or button from working would fail a journey, but it does not name compression as the cause.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.