Setu-TS
    Preparing search index...

    Interface CacheMiddlewareOptions

    Options for the transparent response-caching middleware.

    import { cacheMiddleware } from '@setu-ts/cache-plugin';

    app.router.use('/api/data', cacheMiddleware({ ttlSeconds: 300 }));

    0.1.0

    interface CacheMiddlewareOptions {
        bypass?: (ctx: IRequestContext) => boolean;
        cacheableStatuses?: number[];
        key?: (ctx: IRequestContext) => string;
        store?: string;
        ttlSeconds?: number;
        vary?: (ctx: IRequestContext) => readonly string[];
    }
    Index
    bypass?: (ctx: IRequestContext) => boolean

    Bypass function — when true, skip caching entirely for this request and pass through to the handler.

    cacheableStatuses?: number[]

    HTTP status codes eligible for caching. Defaults to [200].

    key?: (ctx: IRequestContext) => string

    Custom cache key generator. Defaults to ${request.method}:${request.url}.

    The tenant discriminator segment is composed around this key too, so a tenant-aware application stores one entry per tenant regardless.

    store?: string

    Capability token for the cache store to use. Defaults to CAPABILITIES.CACHE.

    ttlSeconds?: number

    Per-route TTL override in seconds.

    vary?: (ctx: IRequestContext) => readonly string[]

    Per-request discriminator values appended to the cache key after the tenant segment. Each returned string is length-prefixed and joined in order, so two requests differing in any value never share an entry. Omitted leaves the key unchanged.