[]previous and next page

CacheEntry

One cached page.

One cached page. Entries are immutable once stored; a store may keep them as objects or serialize them (the key-value adapter does), so they hold only plain data.

Import#

ts
import type { CacheEntry } from "@shadow-js/dusk/server";

Signature#

ts
interface CacheEntry {
  /** Always 200: only successful answers are stored. */
  readonly status: number;
  /** The headers the entry keeps (content type and link hints); everything else is recomputed per answer. */
  readonly headers: readonly (readonly [string, string])[];
  /** The response body, as text. */
  readonly body: string;
  /** The CSP nonce the body was rendered with, if any; a hit rewrites it to the nonce of its own response. */
  readonly nonce: string | undefined;
  /** Strong validator of the body. */
  readonly etag: string;
  /** Epoch milliseconds the page was rendered. */
  readonly storedAt: number;
  /** Epoch milliseconds until which the entry is fresh; `null` when it has no time-based expiry. */
  readonly freshUntil: number | null;
  /** Epoch milliseconds until which a stale entry may still be served; `null` when it never expires. */
  readonly staleUntil: number | null;
  /** The tags the entry is indexed under (always includes its path). */
  readonly tags: readonly string[];
}

Members#

Name Type Description
status readonly status: number Always 200: only successful answers are stored.
headers readonly headers: readonly (readonly [string, string])[] The headers the entry keeps (content type and link hints); everything else is recomputed per answer.
body readonly body: string The response body, as text.
nonce readonly nonce: string | undefined The CSP nonce the body was rendered with, if any; a hit rewrites it to the nonce of its own response.
etag readonly etag: string Strong validator of the body.
storedAt readonly storedAt: number Epoch milliseconds the page was rendered.
freshUntil readonly freshUntil: number | null Epoch milliseconds until which the entry is fresh; null when it has no time-based expiry.
staleUntil readonly staleUntil: number | null Epoch milliseconds until which a stale entry may still be served; null when it never expires.
tags readonly tags: readonly string[] The tags the entry is indexed under (always includes its path).