Skip to content

Add Brotli compression + enable gzip_static / brotli_static #4

@sylvesterdamgaard

Description

@sylvesterdamgaard

Motivation

The current nginx in the base images supports gzip but not Brotli, and neither gzip_static nor brotli_static is wired up.

  • Brotli typically delivers 15–20% better compression than gzip at the same CPU budget. Universally supported in modern browsers (Chrome, Firefox, Safari, Edge — including Safari since 11).
  • Pre-compressed asset serving (gzip_static on / brotli_static on) lets nginx ship the pre-built .gz / .br file straight from disk. Modern build tools (Vite, Webpack, Rollup, esbuild plugins) already produce them as part of the build. Skipping the compression step on every request is a real CPU saving on busy sites — and a moderate latency win even on quiet ones.

Proposal

  • Compile ngx_brotli into the nginx build for all php-fpm-nginx variants
  • Default brotli on; brotli_comp_level 6; (matches gzip default level)
  • Default gzip_static on; brotli_static on; so pre-compressed assets are auto-served when present
  • Surface env vars in line with existing gzip ones:
    • NGINX_BROTLI (default on)
    • NGINX_BROTLI_COMP_LEVEL (default 6)
    • NGINX_BROTLI_TYPES (default mirrors NGINX_GZIP_TYPES)
    • NGINX_GZIP_STATIC / NGINX_BROTLI_STATIC (default on)

Acceptance criteria

  • brotli directives available
  • gzip_static / brotli_static enabled by default
  • Env vars documented
  • Config validation passes when neither .gz nor .br files are present (graceful fallback to dynamic compression)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions