Setu-TS
    Preparing search index...

    Interface CacheApiMiddlewareOptions

    Options for cacheApiMiddleware.

    0.2.0

    interface CacheApiMiddlewareOptions {
        bypass?: (ctx: IRequestContext) => boolean;
        cache?: ICacheApi;
        cacheableStatuses?: readonly number[];
        key?: (ctx: IRequestContext) => string;
        ttlSeconds?: number;
    }
    Index
    bypass?: (ctx: IRequestContext) => boolean

    Returning true skips the cache entirely for this request.

    cache?: ICacheApi

    The cache handle. Omitted resolves caches.default from the global scope; when that is also absent — every runtime other than Cloudflare Workers — the middleware passes through instead of throwing.

    cacheableStatuses?: readonly number[]

    Statuses worth caching. Defaults to [200]. Does not override the platform's unconditional refusal of 206.

    key?: (ctx: IRequestContext) => string

    Builds the cache key from the request. Omitted uses the full request URL, which is what the platform's own cache keys on — plus, when the request carries a resolved ctx.request.tenant (the multi-tenancy plugin) and/or ctx.request.locale (the localization plugin), a setu-cache-tenant and a setu-cache-locale query parameter naming them, appended last. The key is a URL STRING, so the platform matches it with no request headers and Vary cannot separate entries here. The tenant and locale in the key are the ones present when this middleware runs, so it must run AFTER the tenant and locale middleware: a GLOBAL registration needs a higher priority number than theirs (40 and 45 by default, or the configured priorities); where either is applied per route instead, this one must be too, listed after it; and a replaceTenant or replaceLocale made inside the handler is not reflected — such a route must not be cached here. That priority is a LOWER bound only: a global registration still runs before passive authentication (300) and every guard, so a HIT is served without them — inherent to global response caching, as with cache-plugin. A response that depends on who is asking belongs behind a per-route registration listed after its guards. A custom key replaces all of this and must include the tenant and locale itself.

    ttlSeconds?: number

    Adds Cache-Control: public, max-age=<n> to the stored copy when the response carries no Cache-Control of its own. The edge honors the stored response's own directive, so without one an entry has no freshness lifetime and is of little use. The client's response is left untouched.