CacheOptions
Handler options of the cache.
Handler options of the cache.
Import#
ts
import type { CacheOptions } from "@shadow-js/dusk/server";
Signature#
ts
interface CacheOptions {
/** Where pages are kept. Default: a bounded in-process store (`maxEntries`). */
readonly store?: CacheStore;
/** A key-value store for the pages (see `kv-store.ts`); used when `store` is absent. */
readonly kv?: KVStore;
/** Entries of the default store. Default 500. Ignored when `store` is given. */
readonly maxEntries?: number;
/** Largest stored body in bytes; a larger page is answered but not kept. Default 1 MiB. */
readonly maxEntryBytes?: number;
/**
* Keys with a render in flight at once (the bound of coalescing). Past it a request renders on its own, uncoalesced,
* as it would without the cache. Default 10 000.
*/
readonly maxInFlight?: number;
/**
* Requests that share one render. The request past it renders on its own instead of waiting (nothing is refused).
* Default 1 000.
*/
readonly maxWaiters?: number;
/**
* Milliseconds after which a render is abandoned: the requests waiting for it fail, its signal aborts and the key is
* free for a new render. `0` turns the limit off. Default 30 000.
*/
readonly renderTimeoutMs?: number;
/** Wait after the first failed background refresh of a key, in milliseconds; each failure doubles it. Default 1 000. */
readonly backoffBaseMs?: number;
/** Longest wait between two background refreshes of a key that keeps failing, in milliseconds. Default 60 000. */
readonly backoffMaxMs?: number;
/** Clock, in epoch milliseconds. Default `Date.now`; tests pass their own. */
readonly now?: () => number;
/**
* A buffered page that a cache may keep (its `cache-control` is not `no-store`) gets a weak ETag computed from its body,
* so a repeat request with `If-None-Match` gets a 304. Default `true`. `false` turns it off for pages. API answers never
* get one unless the route asks (`event.etag(true)`), and a route's own `ETag` is kept either way.
*/
readonly etag?: boolean;
}
Members#
| Name | Type | Description |
|---|---|---|
store? |
readonly store?: CacheStore |
Where pages are kept. Default: a bounded in-process store (maxEntries). |
kv? |
readonly kv?: KVStore |
A key-value store for the pages (see kv-store.ts); used when store is absent. |
maxEntries? |
readonly maxEntries?: number |
Entries of the default store. Default 500. Ignored when store is given. |
maxEntryBytes? |
readonly maxEntryBytes?: number |
Largest stored body in bytes; a larger page is answered but not kept. Default 1 MiB. |
maxInFlight? |
readonly maxInFlight?: number |
Keys with a render in flight at once (the bound of coalescing). Past it a request renders on its own, uncoalesced, as it would without the cache. Default 10 000. |
maxWaiters? |
readonly maxWaiters?: number |
Requests that share one render. The request past it renders on its own instead of waiting (nothing is refused). Default 1 000. |
renderTimeoutMs? |
readonly renderTimeoutMs?: number |
Milliseconds after which a render is abandoned: the requests waiting for it fail, its signal aborts and the key is free for a new render. 0 turns the limit off. Default 30 000. |
backoffBaseMs? |
readonly backoffBaseMs?: number |
Wait after the first failed background refresh of a key, in milliseconds; each failure doubles it. Default 1 000. |
backoffMaxMs? |
readonly backoffMaxMs?: number |
Longest wait between two background refreshes of a key that keeps failing, in milliseconds. Default 60 000. |
now? |
readonly now?: () => number |
Clock, in epoch milliseconds. Default Date.now; tests pass their own. |
etag? |
readonly etag?: boolean |
A buffered page that a cache may keep (its cache-control is not no-store) gets a weak ETag computed from its body, so a repeat request with If-None-Match gets a 304. Default true. false turns it off for pages. API answers never get one unless the route asks (event.etag(true)), and a route's own ETag is kept either way. |