/** * @jorvel/ssr — request-time ISR (Incremental Static Regeneration). * * Stale-while-revalidate for SSR HTML: serve a cached page instantly; when it's * older than `revalidateMs`, serve the stale copy AND re-render in the * background so the next request is fresh. Complements build-time * `revalidateStaticPages` and the `LruHtmlCache`. * * Bring any {@link HtmlCache} (in-memory default, or a Redis/KV-backed one for * multi-instance). Deduplicates concurrent background regenerations per key. */ import type { HtmlCache } from './html-cache.js'; export interface IsrRenderResult { html: string; status?: number; etag?: string; } export interface ServeIsrOptions { cache: HtmlCache; key: string; /** Produce a fresh page. Called on miss and (in the background) when stale. */ render: () => Promise | IsrRenderResult; /** Serve cached HTML younger than this without regenerating (ms). */ revalidateMs: number; /** Clock (testable). */ now?: () => number; } export interface ServeIsrResult { html: string; status: number; etag: string; /** true when served from cache (fresh OR stale). */ cached: boolean; /** true when served stale + a background revalidation was kicked off. */ stale: boolean; } /** * Serve `key` with ISR semantics. Fresh → cache hit; stale → serve stale + * background regenerate; miss → render synchronously and cache. */ export declare function serveWithISR(opts: ServeIsrOptions): Promise; /** Await any in-flight background regeneration for a key (tests / graceful shutdown). */ export declare function awaitIsrRevalidation(key: string): Promise; //# sourceMappingURL=isr.d.ts.map