import type { MiddlewareHandler } from "hono"; import type { VoyantBindings } from "../types.js"; /** * Options for {@link publicResponseCache}. */ export interface PublicCacheOptions { /** * Path prefixes eligible for caching. Defaults to the public API * surface only — admin and legacy surfaces are never cached. */ pathPrefixes?: string[]; /** * Responses larger than this (in bytes, after text decoding) are not * stored in the KV fallback. Protects isolate memory and KV value * limits. Default 2 MiB. The Cache API path streams and is not * subject to this guard. */ maxKvBodyBytes?: number; } /** Test hook — resets the memoized Cache API probe state. */ export declare function resetPublicCacheStateForTests(): void; /** * Shared response cache for the public API surface. * * Fail-closed by design: a response is only ever cached when the route * explicitly marked it shareable — `Cache-Control` containing `public` * AND a positive `s-maxage` — and it carries no `Set-Cookie`. Routes * emit `private`/`no-store` (or nothing) to opt out, so personalized * endpoints under `/v1/public/*` (customer portal, verification) are * never cached by accident. * * Cache hits are served before auth, the DB middleware, and the runtime * bootstrap — a hit costs no Postgres connection, no session lookup, * and no module-graph instantiation, which is the entire point under * storefront load (#1686). * * Backend selection: the injected `env.CACHE` {@link KVStore}. Node * composition decides whether that is memory, Postgres, Redis, or a tiered * store; this middleware never probes a global runtime cache. */ export declare function publicResponseCache(options?: PublicCacheOptions): MiddlewareHandler<{ Bindings: TBindings; }>;