livery_etag (livery v0.2.0)
View SourceETag / conditional-GET middleware.
For cacheable GET/HEAD responses it ensures an ETag header and
answers 304 Not Modified when the request's If-None-Match matches,
skipping the body transfer.
Stack = [{livery_etag, #{}} | Rest].By default a strong ETag is computed automatically from a {full, _}
body that has no ETag; a handler may instead set its own (via
livery_resp:with_etag/2), which is respected on ANY body variant.
Config keys (all optional): auto (default true), weak (default
false, auto ETags are strong), statuses (cacheable statuses, default
[200]).
Placement: put livery_etag OUTSIDE livery_compress (earlier in the
stack list) so the ETag covers the bytes actually sent; otherwise the
ETag is of the uncompressed body and you rely on Vary: Accept-Encoding
(which livery_compress already sets).
Summary
Functions
Add an ETag and answer 304 on a matching conditional GET.
True if the request's If-None-Match matches ETag.
Functions
-spec call(livery_req:req(), livery_middleware:next(), map() | undefined) -> livery_resp:resp().
Add an ETag and answer 304 on a matching conditional GET.
-spec if_none_match(livery_req:req(), binary()) -> boolean().
True if the request's If-None-Match matches ETag.
Honors * and uses RFC 9110 weak comparison. Exposed so other handlers
(e.g. livery_static) share one conditional-request implementation.