/** * Page cache service with ISR (Incremental Static Regeneration) support. * Handles stale-while-revalidate semantics and background regeneration. * @module */ import type { EcoPagesAppConfig } from '../../types/internal-types.js'; import type { CacheResult, CacheStore, CacheStrategy, RenderResult } from './cache.types.js'; import { HtmlPageCacheDependencyIndex } from './html-page-cache-dependency-index.js'; export interface PageCacheServiceOptions { store?: CacheStore; enabled?: boolean; dependencyIndex?: HtmlPageCacheDependencyIndex; } /** * Core page caching service with ISR support. */ export declare class PageCacheService { private store; private enabled; private readonly dependencyIndex; private regenerationPromises; private missPromises; constructor(options?: PageCacheServiceOptions); /** * Generate a cache key from URL and optional params. * Uses full URL (path + query) as the key. */ generateCacheKey(url: string): string; /** * Check if an entry is stale (past its revalidation time). */ private isStale; /** * Create a cache entry from rendered HTML. */ private createEntry; /** * Get cached content or create new content with stale-while-revalidate semantics. * @param key - Cache key (URL path + query) * @param defaultStrategy - Default strategy if page doesn't specify one * @param renderFn - Function that renders the page and returns HTML + strategy */ getOrCreate(key: string, defaultStrategy: CacheStrategy, renderFn: () => Promise, options?: { sourceDependencyPaths?: readonly string[]; }): Promise; private resolveOrCreate; private registerDependencyPaths; /** * Regenerate content in the background without blocking the response. * Uses promise deduplication to prevent multiple concurrent regenerations. */ private regenerateInBackground; /** * Invalidate cache entries by tags. */ invalidateByTags(tags: string[]): Promise; /** * Invalidate cache entries by paths. */ invalidateByPaths(paths: string[]): Promise; /** * Invalidates cached HTML entries that registered the given source paths. */ invalidateBySourceDependencyPaths(sourcePaths: readonly string[]): Promise; getDependencyIndex(): HtmlPageCacheDependencyIndex; /** * Clear all cached entries. */ clear(): Promise; /** * Get cache statistics. */ stats(): Promise; /** * Get the underlying cache store. */ getStore(): CacheStore; } /** * Generate Cache-Control header value from cache strategy. */ export declare function getCacheControlHeader(strategy: CacheStrategy | 'disabled'): string; /** * Registers the page cache service for one app config instance. */ export declare function registerAppPageCacheService(appConfig: EcoPagesAppConfig, service: PageCacheService | null): void; /** * Returns the registered page cache service for one app config, if any. */ export declare function getAppPageCacheService(appConfig: EcoPagesAppConfig): PageCacheService | null; /** * Clears rendered HTML cache entries for one app during development invalidation. */ export declare function clearAppPageCache(appConfig: EcoPagesAppConfig): Promise; /** * Invalidates rendered HTML cache entries that depend on the given source paths. */ export declare function invalidateAppPageCacheBySourcePaths(appConfig: EcoPagesAppConfig, sourcePaths: readonly string[]): Promise;