Tapak_compressions.PredicatePredicates for deciding whether to compress HTTP responses.
Predicates can be composed using boolean operators to create complex compression rules.
type t = Tapak_kernel.Request.t -> Tapak_kernel.Response.t -> boolThe type of a compression predicate. Takes a request and response, returns true if the response should be compressed.
val always : tAlways compress
val never : tNever compress
val min_size : int -> tCompress if content-length is above threshold. If Content-Length header is missing, defaults to true (compress). This is appropriate for streaming responses.
val content_type_matches : string list -> tCompress only specific content types. Content-Type is compared case-insensitively, and parameters (like charset) are ignored.
val compressible_content_type : tCompress common text-based content types:
val not_already_compressed : tDon't compress already-compressed content types like:
val not_already_encoded : tDon't compress if response already has Content-Encoding header
val respect_no_transform : tDon't compress if Cache-Control: no-transform is present (RFC 7234)
val has_body : tDon't compress certain status codes that don't have bodies (1xx, 204 No Content, 304 Not Modified)
val default_predicate : tDefault predicate combining sensible defaults:
Equivalent to:
min_size 32
&& compressible_content_type
&& not_already_encoded
&& respect_no_transform
&& has_body