trillium-static-compiled-v0.7.0
·
125 commits
to main
since this release
Added
- HTTP Range request support. Every response advertises
Accept-Ranges: bytes. When a client sends a single-rangeRange: bytes=...header
(START-END,START-, or-SUFFIX), the handler returns just that
byte range with status206 Partial Content,Content-Range, and
Content-Length. Out-of-bounds ranges return416 Requested Range Not SatisfiablewithContent-Range: bytes */N. Multi-range requests fall
through to a200full body. HonorsIf-Range(strong-comparison only
per RFC 9110) against the precomputed strong etag orLast-Modified
date. Ranged requests bypassAccept-Encodingnegotiation — the range
applies to the identity representation. - Compile-time entity-tag computation, on by default. The macro hashes each
file's source bytes viaetag::EntityTag::from_dataand bakes the
resulting tag string as a&'static str; the handler emits it as the
ETagresponse header (one tag per source, applied to all encodings).
Opt out per invocation withstatic_compiled!("./files", etag = false).
The baked tag is byte-identical to whattrillium_caching_headers::Etag
would compute at runtime, so chainingEtag::new()after this handler
composes naturally — that handler observes the precomputed tag, skips
rehashing the body, and handlesIf-None-Match/304 Not Modified. - Compile-time precompression of file contents into Brotli, Zstd, and Gzip
variants, gated behind opt-in cargo features (brotli,zstd,gzip,
or thecompressionmeta-feature) and an opt-in macro argument:
static_compiled!("./files", compress)bakes every variant whose feature
is enabled, andstatic_compiled!("./files", compress = [Brotli, Gzip])
bakes a specified subset. Encoders run at maximum quality in parallel via
rayon. Per-file variants are sorted smallest-first, and only baked when
they beat the source by at least 5%; files under 256 bytes are skipped
entirely. The handler picks the smallest variant the client's
Accept-Encodingallows, setsContent-Encoding, and emits
Vary: Accept-Encoding(per-file, only when variants are baked).
Composes withtrillium-compression, which passes through any response
that already hasContent-Encodingset. - Public
Encodingenum withEncoding::token()returning the HTTP
content-coding token, andFile::with_encodings,File::encodings, and
File::pick_encodingfor inspecting baked variants.