How google/ngx_brotli works
ngx_brotli adds two response-serving capabilities to Nginx: dynamic Brotli compression and delivery of pre-compressed .br files. In the dynamic path, Nginx response filtering checks request eligibility and configured compression settings, then uses the Brotli encoder; in the static path, the module checks eligibility, reads a compressed file, and prepares the response. The excerpts show these paths and filesystem access, while the README documents the user-facing capabilities and directives; wiring details beyond that evidence are omitted.
Main entry points: ngx_http_brotli_filter_module.c Brotli filter · ngx_http_brotli_static_module.c Static handler
Components 6
Dynamic compression
- Brotli filter
filter/ngx_http_brotli_filter_module.c - Brotli encoder
Static delivery
- Static handler
static/ngx_http_brotli_static_module.c - Compressed files
Other components
- HTTP client
- Nginx HTTP
Connections 7
- HTTP client → Nginx HTTP: sends request
README.md - Nginx HTTP → Brotli filter: filters responses
README.md - Brotli filter → Brotli encoder: compresses with
filter/ngx_http_brotli_filter_module.c - Brotli filter → Nginx HTTP: passes response
filter/ngx_http_brotli_filter_module.c - Nginx HTTP → Static handler: serves files via
README.md - Static handler → Compressed files: reads `.br` file
static/ngx_http_brotli_static_module.c - Static handler → HTTP client: sends compressed response
static/ngx_http_brotli_static_module.c