evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Fetches JSON resources with a persistent cache that supports offline reads, stale reuse, and explicit reloads.
cacheDirectory for persistent storage; set cacheStatus from cache metadata headers (e.g., x-local-cache-status) or to null when absent; set fromCache when metadata indicates a cache hit (hit, stale, revalidated, or updated); set revalidated when metadata reports a conditional validation instead of a full fetch.offline by avoiding network requests entirely and letting the dependency surface its cache-miss error if no entry exists.reload is requested, bypass any cached copy and replace it with a fresh response.export interface CachedFetchOptions {
cacheDirectory: string;
offline?: boolean;
reload?: boolean;
requestInit?: RequestInit;
}
export interface CachedFetchResult<T = unknown> {
status: number;
data: T;
fromCache: boolean;
cacheStatus?: string | null;
revalidated?: boolean;
}
export async function fetchJsonWithCache<T = unknown>(
url: string,
options: CachedFetchOptions
): Promise<CachedFetchResult<T>>;HTTP client with persistent caching, revalidation, and offline cache-only mode.