Skip to content

Etag.ts

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.

Since v4.0.0



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

Signature

declare const toString: (self: Etag) => string

Source

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, never, never>

Source

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, never, never>

Source

Since v4.0.0

Represents an HTTP entity tag, either weak or strong.

Signature

type Etag = Weak | Strong

Source

Since v4.0.0

Service for generating ETags from filesystem file information or Web File-like metadata.

Signature

declare class Generator

Source

Since v4.0.0

Strong HTTP entity tag.

Details

The value is the raw tag value without the surrounding quotes.

Signature

export interface Strong {
readonly _tag: "Strong"
readonly value: string
}

Source

Since v4.0.0

Weak HTTP entity tag.

Details

The value is the raw tag value without the surrounding quotes or W/ prefix.

Signature

export interface Weak {
readonly _tag: "Weak"
readonly value: string
}

Source

Since v4.0.0