astro
Version:
Astro is a modern site builder with web best practices, performance, and DX front-of-mind.
36 lines (35 loc) • 1.72 kB
TypeScript
import type { FetchState } from '../fetch/fetch-state.js';
import type { SSRManifest } from '../app/types.js';
import { type CompiledCacheRoute } from './runtime/route-matching.js';
/**
* Registers a cache provider on the given `FetchState`. When
* `state.resolve('cache')` is first called, the appropriate cache
* implementation is created (disabled, noop for dev, or real).
*
* Returns synchronously when cache is not configured or in dev mode.
*/
export declare function provideCache(state: FetchState): Promise<void> | void;
/**
* Wraps a render callback with cache provider logic. Handles both
* runtime caching (onRequest) and CDN-based providers (headers only).
*
* - When a cache provider with `onRequest` is configured, the callback
* is wrapped so the provider can serve from cache or fall through.
* - When only CDN headers are needed, the callback runs directly and
* cache headers are applied to the response.
* - When no cache provider is configured, the callback runs as-is.
*
* Cache headers (`CDN-Cache-Control`, `Cache-Tag`) are stripped from
* the final response after the runtime provider has read them.
*/
export declare function handleCache(state: FetchState, next: () => Promise<Response>): Promise<Response>;
/**
* Config-level cache routes compiled from `manifest.cacheConfig`, derived
* lazily on the first cache-seeded request.
*/
export declare function getCompiledCacheRoutes(manifest: SSRManifest): CompiledCacheRoute[];
/**
* Internal raw setter — exists only so the transitional `Pipeline` bridge can
* expose `compiledCacheRoutes` as a get/set pair.
*/
export declare function setCompiledCacheRoutes(manifest: SSRManifest, routes: CompiledCacheRoute[]): void;