mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +03:00
implement transparent gzip compression in the webserver
we only compress if applicable (content-type indicates likely compressible), client supports it, response doesn't already have a content-encoding). for internal handlers, we always enable compression. for reverse proxied and static files, compression must be enabled per handler. for internal & reverse proxy handlers, we do streaming compression at "bestspeed" quality (probably level 1). for static files, we have a cache based on mtime with fixed max size, where we evict based on least recently used. we compress with the default level (more cpu, better ratio).
This commit is contained in:
@ -1938,7 +1938,8 @@ const webserver = async () => {
|
||||
dom.td('LogName', attr({title: 'Name used during logging for requests matching this handler. If empty, the index of the handler in the list is used.'})),
|
||||
dom.td('Domain', attr({title: 'Request must be for this domain to match this handler.'})),
|
||||
dom.td('Path Regexp', attr({title: 'Request must match this path regular expression to match this handler. Must start with with a ^.'})),
|
||||
dom.td('To HTTPS', attr({title: 'Redirect plain HTTP (non-TLS) requests to HTTPS'})),
|
||||
dom.td('To HTTPS', attr({title: 'Redirect plain HTTP (non-TLS) requests to HTTPS.'})),
|
||||
dom.td('Compress', attr({title: 'Transparently compress responses (currently with gzip) if the client supports it, the status is 200 OK, no Content-Encoding is set on the response yet and the Content-Type of the response hints that the data is compressible (text/..., specific application/... and .../...+json and .../...+xml). For static files only, a cache with compressed files is kept.'})),
|
||||
),
|
||||
dom.tr(
|
||||
dom.td(
|
||||
@ -1953,6 +1954,9 @@ const webserver = async () => {
|
||||
dom.td(
|
||||
row.ToHTTPS=dom.input(attr({type: 'checkbox', title: 'Redirect plain HTTP (non-TLS) requests to HTTPS'}), !wh.DontRedirectPlainHTTP ? attr({checked: ''}) : []),
|
||||
),
|
||||
dom.td(
|
||||
row.Compress=dom.input(attr({type: 'checkbox', title: 'Transparently compress responses.'}), wh.Compress ? attr({checked: ''}) : []),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Replaced with a call to makeType, below (and later when switching types).
|
||||
@ -2008,6 +2012,7 @@ const webserver = async () => {
|
||||
Domain: row.Domain.value,
|
||||
PathRegexp: row.PathRegexp.value,
|
||||
DontRedirectPlainHTTP: !row.ToHTTPS.checked,
|
||||
Compress: row.Compress.checked,
|
||||
}
|
||||
const s = row.type.value
|
||||
const details = row.getDetails()
|
||||
|
Reference in New Issue
Block a user