[]previous and next page

PwaRuntimeRule

One runtime caching rule: which requests it covers and how they are answered.

One runtime caching rule: which requests it covers and how they are answered.

Import#

ts
import type { PwaRuntimeRule } from "@shadow-js/dusk/vite";

Signature#

ts
interface PwaRuntimeRule {
  /** Glob (or globs) of the path below the mount base: `/api/**`, `/images/*.{png,jpg}`. The first rule that matches wins. */
  readonly pattern: string | readonly string[];
  /** `network-first`, `cache-first` or `stale-while-revalidate`. */
  readonly strategy: CacheStrategy;
  /** A name for this rule's cache (letters, digits, dashes). Default: `rule<position>`. */
  readonly cacheName?: string;
  /** The most entries the cache keeps; the oldest are deleted first. `0` is no limit. Default 50. */
  readonly maxEntries?: number;
  /** Seconds a kept answer is used. `0` is no limit. Default 30 days. */
  readonly maxAgeSeconds?: number;
  /** `network-first` only: seconds to wait for the network before the kept answer is used. Default 0 (wait). */
  readonly networkTimeoutSeconds?: number;
}

Members#

Name Type Description
pattern readonly pattern: string | readonly string[] Glob (or globs) of the path below the mount base: /api/**, /images/*.{png,jpg}. The first rule that matches wins.
strategy readonly strategy: CacheStrategy network-first, cache-first or stale-while-revalidate.
cacheName? readonly cacheName?: string A name for this rule's cache (letters, digits, dashes). Default: rule<position>.
maxEntries? readonly maxEntries?: number The most entries the cache keeps; the oldest are deleted first. 0 is no limit. Default 50.
maxAgeSeconds? readonly maxAgeSeconds?: number Seconds a kept answer is used. 0 is no limit. Default 30 days.
networkTimeoutSeconds? readonly networkTimeoutSeconds?: number network-first only: seconds to wait for the network before the kept answer is used. Default 0 (wait).