Etag
HTTP entity tag values and metadata-based generator layers.
ETags are validators for a specific representation of a resource. Servers put them in ETag response headers so clients and intermediaries can revalidate cached content with If-None-Match, or protect writes with preconditions such as If-Match.
Converting
Layers
Layer that provides a Generator which produces strong ETags from file size and modification time metadata.
When to use
Use when you need the Generator service to produce strong ETags and file size plus modification time reliably change for every byte-level change.
Gotchas
This layer marks metadata-derived tags as strong. If the underlying storage can update file contents without changing the recorded size or modification time, those tags can stop representing byte-for-byte identity.
See
Signature
declare const layer: Layer.Layer<Generator>;Layer that provides a Generator which produces weak ETags from file size and modification time metadata.
Signature
declare const layerWeak: Layer.Layer<Generator>;Models
Represents an HTTP entity tag, either weak or strong.
Signature
type Etag = Weak | Strong;Strong HTTP entity tag.
Details
The value is the raw tag value without the surrounding quotes.
Signature
interface Strong {
readonly _tag: "Strong";
readonly value: string;
}Weak HTTP entity tag.
Details
The value is the raw tag value without the surrounding quotes or W/ prefix.
Signature
interface Weak {
readonly _tag: "Weak";
readonly value: string;
}Services
Service for generating ETags from filesystem file information or Web File-like metadata.
Signature
declare class Generator extends Shape<
"effect/http/Etag/Generator",
{
readonly fromFileInfo: (info: Info) => Effect<Etag>;
readonly fromFileWeb: (file: FileLike) => Effect<Etag>;
},
this
> {
constructor(_: never);
}
Formats an
Etagas an HTTP header value, including quotes and theW/prefix for weak tags.