Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

Etag unstable

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.

7 exports Since v4.0.0 Source

Converting

toString

unstable
Since v4.0.0

Formats an Etag as an HTTP header value, including quotes and the W/ prefix for weak tags.

Signature

declare function toString(self: Etag): string

Layers

layer

unstable
Since v4.0.0

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

  • layerWeak for weak metadata-derived ETags when byte-for-byte identity is not required
  • Generator for the service provided by this layer

Signature

declare const layer: Layer.Layer<Generator>

layerWeak

unstable
Since v4.0.0

Layer that provides a Generator which produces weak ETags from file size and modification time metadata.

Signature

declare const layerWeak: Layer.Layer<Generator>

Models

Etag

type unstable
Since v4.0.0

Represents an HTTP entity tag, either weak or strong.

Signature

type Etag = Weak | Strong

Strong

interface unstable
Since v4.0.0

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

interface unstable
Since v4.0.0

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

Generator

unstable
Since v4.0.0

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);
}