import type { Context, Env, MiddlewareHandler } from 'hono'; import type * as z from 'zod/mini'; /** * Named `Cache-Control` policies, tiered by how volatile each resource is. The * `max-age` bounds how stale a shared (edge) hit can be; `stale-while-revalidate` * lets clients/CDNs serve a slightly older copy while refreshing in the * background. Handlers may override per response via `Cache.setPolicy` (e.g. a * mined transaction is `immutable`, a pending one is `noStore`). */ export declare const policies: { /** * Publicly shareable binary assets (token logos). `public` because the bytes * carry no per-principal data and the edge layer strips per-request headers. * Deliberately NOT `immutable`: these live at a stable URL * (`/tokens/:token/logo`) whose underlying R2 icon can be replaced in place * (admin upload), so a long `max-age` is paired with `stale-while-revalidate` * to revalidate rather than pin a replaced logo for a year. Use a versioned/ * content-addressed URL if true `immutable` forever-caching is needed. */ readonly asset: 'public, max-age=86400, stale-while-revalidate=604800'; /** Fallback for routes that do not specify a policy. */ readonly default: 'private, max-age=30, stale-while-revalidate=300'; /** Newest-first feeds (transactions, receipts, transfers): refresh quickly. */ readonly feed: 'private, max-age=10, stale-while-revalidate=30'; /** Immutable resources (mined transactions and receipts): cache aggressively. */ readonly immutable: 'private, max-age=86400, stale-while-revalidate=604800'; /** Token metadata and indexed listings: change slowly. */ readonly metadata: 'private, max-age=60, stale-while-revalidate=300'; /** Transient or uncacheable responses (pending transactions). */ readonly noStore: 'no-store'; /** Slow-changing curated data (verified tokens). */ readonly stable: 'private, max-age=300, stale-while-revalidate=3600'; /** Current-state pages (holders, balances): moderately volatile. */ readonly state: 'private, max-age=30, stale-while-revalidate=120'; }; /** * Overrides the cache policy for the current response, taking precedence over * the route's default `Cache.response` policy. Lets a handler vary caching by * outcome — e.g. cache a mined transaction as `immutable` but a pending one as * `noStore`. Must be called before the handler returns. */ export declare function setPolicy(c: Context, cacheControl: string): void; /** Hono response-cache helpers. */ export declare function response(options: response.Options): MiddlewareHandler; export declare namespace response { /** Options for response caching. */ type Options = { /** Cache-control value returned to clients. */ cacheControl?: string | undefined; /** Cache name passed to Hono's cache middleware. */ name: string; /** Cache key generator. */ key: (c: Context) => Promise | string; /** Vary headers used for the response and cache key. */ vary?: readonly string[] | undefined; }; } export declare namespace response { /** Per-request headers that must not be stored in shared response caches. */ const preservedHeaders: string[]; } /** * Builds a cache key from the request URL after parsing query params through * the given Zod schema. Defaults from the schema are baked into the key so * cached entries collide regardless of param ordering, casing, or omitted * defaults. Resolves an optional `chainId` query parameter against the app's * default chain id when the caller did not provide one. */ export declare function urlKey(c: Context, schema: schema): string; //# sourceMappingURL=Cache.d.ts.map