Libraries
    Preparing search index...

    Function cacheResponse

    • Server-side cache response middleware.

      Uses cache-tag definitions from the matched endpoint (already available on ctx.items.__endpoint_meta.cacheTags) to compute deterministic cache keys from request data (params, query, body, headers).

      • GET: Computes cache key → serves cached response if valid → handler never executes. On cache miss, runs the handler and caches the response.
      • Mutation (POST/PUT/PATCH/DELETE): Lets the handler run, then invalidates all cache entries whose key starts with any of the endpoint's cache tag names.

      Parameters

      Returns Middleware

      A server-side Middleware.

      server.handle(ListTodos, listHandler, {
      middlewares: [cacheResponse({ defaultTtl: 30_000 })]
      });