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
Motivation
The current nginx in the base images supports gzip but not Brotli, and neither
gzip_staticnorbrotli_staticis wired up.gzip_static on/brotli_static on) lets nginx ship the pre-built.gz/.brfile 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
ngx_brotliinto the nginx build for allphp-fpm-nginxvariantsbrotli on; brotli_comp_level 6;(matches gzip default level)gzip_static on; brotli_static on;so pre-compressed assets are auto-served when presentNGINX_BROTLI(defaulton)NGINX_BROTLI_COMP_LEVEL(default6)NGINX_BROTLI_TYPES(default mirrorsNGINX_GZIP_TYPES)NGINX_GZIP_STATIC/NGINX_BROTLI_STATIC(defaulton)Acceptance criteria
brotlidirectives availablegzip_static/brotli_staticenabled by default.gznor.brfiles are present (graceful fallback to dynamic compression)