/** * API Response Caching Layer * * Implements HTTP caching for API responses */ interface CacheOptions { ttl?: number; staleWhileRevalidate?: number; tags?: string[]; vary?: string[]; private?: boolean; noStore?: boolean; } /** * Generate cache key from request */ export declare function generateCacheKey(request: Request): string; /** * Get cached response */ export declare function getCachedResponse(request: Request): Promise; /** * Set cached response */ export declare function setCachedResponse(request: Request, response: Response, options?: CacheOptions): Promise; /** * Invalidate cache by key */ export declare function invalidateCacheKey(key: string): void; /** * Invalidate cache by pattern */ export declare function invalidateCachePattern(pattern: string): number; /** * Invalidate cache by tags */ export declare function invalidateCacheTags(tags: string[]): number; /** * Clear all cache */ export declare function clearCache(): void; /** * Set Cache-Control headers */ export declare function setCacheHeaders(response: Response, options: CacheOptions): Response; /** * Create caching middleware */ export declare function createCacheMiddleware(options?: CacheOptions): (request: Request, next: () => Promise) => Promise; /** * Get cache statistics */ export declare function getCacheStats(): { totalEntries: number; validEntries: number; expiredEntries: number; totalSize: number; averageSize: number; }; /** * Purge expired entries */ export declare function purgeExpiredCache(): number; /** * Start cache cleanup interval */ export declare function startCacheCleanup(intervalMs?: number): NodeJS.Timeout; /** * Cache response with ETag */ export declare function withETag(response: Response, content: string): Response; /** * Check if request has matching ETag */ export declare function checkETag(request: Request, etag: string): boolean; /** * Create 304 Not Modified response */ export declare function createNotModifiedResponse(): Response; /** * Cache presets for common scenarios */ export declare const CACHE_PRESETS: { readonly noCache: { readonly noStore: true; }; readonly short: { readonly ttl: 60; readonly staleWhileRevalidate: 30; }; readonly medium: { readonly ttl: 300; readonly staleWhileRevalidate: 60; }; readonly long: { readonly ttl: 3600; readonly staleWhileRevalidate: 300; }; readonly veryLong: { readonly ttl: 86400; readonly staleWhileRevalidate: 3600; }; readonly immutable: { readonly ttl: 31536000; readonly private: false; }; readonly private: { readonly ttl: 300; readonly private: true; }; readonly public: { readonly ttl: 3600; readonly private: false; }; }; /** * Cache API response */ export declare function cacheAPIResponse(key: string, responseFn: () => Promise, options?: CacheOptions): Promise<{ data: T; cached: boolean; }>; export {}; //# sourceMappingURL=response-cache.d.ts.map