# Brotli compression is enabled for text assets

- **Pattern:** `ab-001801` (`marketing-page-speed.infrastructure.compression-brotli`)
- **Severity:** medium
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-001801
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-001801)

## Why it matters

Uncompressed text assets — HTML, CSS, and JavaScript — transfer at their full source size over the network. Brotli compression reduces text payload by 15–25% compared to gzip, and 60–80% compared to uncompressed, which directly maps to the ISO-25010 resource-utilisation quality attribute. A 200KB JavaScript bundle served uncompressed arrives as 200KB; with Brotli it arrives as approximately 45KB. At 4G speeds, that's roughly 250ms of avoidable download time per bundle. Marketing pages with multiple JS chunks and third-party scripts compound this: every uncompressed text resource adds to the total transfer time that feeds into FCP and LCP. Serving `compress: false` without an external compression layer is an explicit choice to send more bytes than necessary.

## Severity rationale

Medium because disabling compression adds 60–80% to text asset payload, measurably increasing FCP and LCP, but Brotli is automatic on modern hosting platforms so the failure only occurs on custom server configurations.

## Remediation

Verify compression is enabled and not explicitly disabled in your Next.js configuration — the default is `compress: true`.

```ts
// next.config.ts — ensure this is not present
// compress: false  ← remove this if it exists

// Correct default
const nextConfig = {
  compress: true, // gzip compression via Next.js server
}
```

On Vercel and Netlify, Brotli is applied automatically at the CDN layer — no configuration needed. For custom nginx servers:

```nginx
# nginx.conf
brotli on;
brotli_types text/html text/css application/javascript application/json;
brotli_comp_level 6;
```

Verify compression is active by checking the `Content-Encoding` response header: `curl -H 'Accept-Encoding: br' -I https://yoursite.com` should return `content-encoding: br`.

## Detection

- **ID:** `compression-brotli`
- **Severity:** `medium`
- **What to look for:** Brotli compression achieves 15-25% better compression than gzip for text assets (HTML, CSS, JS) and is supported by all modern browsers. Check: (1) hosting config for compression settings, (2) whether the hosting platform enables Brotli by default (Vercel: yes, Netlify: yes, Cloudflare: yes, raw nginx: must configure), (3) `next.config.*` for compression settings (`compress: true` is the default), (4) custom server middleware for compression. Note: gzip is acceptable but Brotli is preferred. Count all instances found and enumerate each.
- **Pass criteria:** Text assets are compressed with Brotli (`Content-Encoding: br` in response headers). Gzip compression (`Content-Encoding: gzip`) is acceptable as a fallback. On Vercel, Netlify, and Cloudflare, Brotli is automatic. At least 1 implementation must be confirmed.
- **Fail criteria:** Text assets are served uncompressed. No compression configured on custom server. `compress: false` in Next.js config without an alternative compression layer.
- **Skip (N/A) when:** Project is not yet deployed (no hosting config detected).
- **Detail on fail:** `"compress: false in next.config.ts with no external compression layer configured. Serving uncompressed JS/CSS — adds ~70% to text asset payload."`
- **Remediation:** Enable compression at the hosting layer:

  ```ts
  // next.config.ts — ensure compression is on (default is true)
  const nextConfig = {
    compress: true, // enables gzip compression in the Next.js server
  }
  ```

  On Vercel and Netlify, Brotli is automatic and requires no configuration. On custom servers:

  ```nginx
  # nginx
  brotli on;
  brotli_types text/html text/css application/javascript;
  brotli_comp_level 6;
  ```

## External references

- iso-25010 performance-efficiency.resource-utilization

Taxons: performance

HTML version: https://auditbuffet.com/patterns/ab-001801
