inkan

Compress

Brotli or gzip, as the client takes it.

import {  } from "@vxnsin/inkan";

.(());

Compresses answers with brotli or gzip, whichever the client's accept-encoding takes, and says so in content-encoding and vary. Streams are compressed as they go; server-sent events are left alone, so every event arrives when it is sent. Small bodies, HEAD, 204 and 304 go as they are. From 0.7.0 it runs after every other onSend hook, wherever it was registered, so a hook that reads the body (an ETag) sees it unpacked.

Options

optiondefault
threshold1024bodies smaller than this many bytes go as they are
encodings["br", "gzip"]which encodings to offer, best first
filtertext, JSON, JavaScript, XML, SVG, WebAssembly(contentType) => boolean: whether a media type is worth compressing

Behind a proxy that compresses already, leave it out.

On this page