http-strip-filter #
Minifies HTML, CSS, JavaScript, JSON, SVG and XML response bodies on the fly. Use it to save bandwidth on text responses when you cannot minify at build time. The default mode is conservative; strip_aggressive enables the riskier byte-level changes.
Source: our fork on GitHub
Directives
strip #
syntax: strip on | off (on/off flag); · context: http, server, location
It disables nginx's rewrite and gzip modules only to avoid unrelated PCRE and zlib build dependencies; the strip filter itself does not require either library. ## Testing Two suites, deliberately separate. Core unit tests — strip_core.c has no nginx dependency, so its state machines are driven directly.
strip_aggressive #
syntax: strip_aggressive on | off (on/off flag); · context: http, server, location
Set > strip_aggressive on; to restore the historical byte-level behavior.
strip_css #
syntax: strip_css on | off (on/off flag); · context: http, server, location
Enable strip_js/strip_css to minify standalone .js/.css files separately. - strip_js on; is intentionally byte-identical unless strip_aggressive on; is also set.
strip_js #
syntax: strip_js on | off (on/off flag); · context: http, server, location
Enable strip_js/strip_css to minify standalone .js/.css files separately. - strip_js on; is intentionally byte-identical unless strip_aggressive on; is also set.
strip_json #
syntax: strip_json on | off (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
strip_max_size #
syntax: strip_max_size 1 arg (size (k/m/g)); · context: http, server, location
Buffering is bounded only in size, by strip_max_size: once the accumulated body exceeds that many bytes the filter stops buffering and passes the remainder through.
strip_min_size #
syntax: strip_min_size 1 arg (size (k/m/g)); · context: http, server, location
Size in bytes; accepts k / m / g suffixes.
strip_svg #
syntax: strip_svg on | off (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
strip_types #
syntax: strip_types 1+ args; · context: http, server, location
Adds MIME types, beyond text/html, that the HTML-stripping filter processes.
strip_xml #
syntax: strip_xml on | off (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
Example
load_module modules/ngx_http_strip_filter_module.so;
http {
server {
strip on; # HTML
strip_css on;
strip_js on;
strip_json on;
}
}