Skip to content

trillium-static-compiled-v0.7.0

Choose a tag to compare

@github-actions github-actions released this 10 May 04:33
· 125 commits to main since this release

Added

  • HTTP Range request support. Every response advertises Accept-Ranges: bytes. When a client sends a single-range Range: bytes=... header
    (START-END, START-, or -SUFFIX), the handler returns just that
    byte range with status 206 Partial Content, Content-Range, and
    Content-Length. Out-of-bounds ranges return 416 Requested Range Not Satisfiable with Content-Range: bytes */N. Multi-range requests fall
    through to a 200 full body. Honors If-Range (strong-comparison only
    per RFC 9110) against the precomputed strong etag or Last-Modified
    date. Ranged requests bypass Accept-Encoding negotiation — the range
    applies to the identity representation.
  • Compile-time entity-tag computation, on by default. The macro hashes each
    file's source bytes via etag::EntityTag::from_data and bakes the
    resulting tag string as a &'static str; the handler emits it as the
    ETag response header (one tag per source, applied to all encodings).
    Opt out per invocation with static_compiled!("./files", etag = false).
    The baked tag is byte-identical to what trillium_caching_headers::Etag
    would compute at runtime, so chaining Etag::new() after this handler
    composes naturally — that handler observes the precomputed tag, skips
    rehashing the body, and handles If-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 the compression meta-feature) and an opt-in macro argument:
    static_compiled!("./files", compress) bakes every variant whose feature
    is enabled, and static_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-Encoding allows, sets Content-Encoding, and emits
    Vary: Accept-Encoding (per-file, only when variants are baked).
    Composes with trillium-compression, which passes through any response
    that already has Content-Encoding set.
  • Public Encoding enum with Encoding::token() returning the HTTP
    content-coding token, and File::with_encodings, File::encodings, and
    File::pick_encoding for inspecting baked variants.