HTTP response caching middleware for Koa (v5.0.2, requires Node >=18). Supports any store (memory, Redis, etc.) via async get/set functions. Handles JSON/stream bodies, gzip compression (opt-in since v4), and 304 responses. Differentiator: minimal, store-agnostic design compared to heavier solutions like koa-response-cache. Pairs well with @ladjs/koa-cache-responses for advanced caching. Active development with periodic releases.
npm install koa-cashNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows ESM import, store setup with get/set using Map, and ctx.cashed() pattern for caching responses. Uses TypeScript type assertions.
Use dynamic import or switch to ES modules. If using TypeScript, set type: 'module' or use .mts.
Pass { compression: true } explicitly if you need gzip compression.Check maxAge parameter in get/set and apply TTL in your store (e.g., lru-cache maxAge option).
Pass maxAge as second argument: await ctx.cashed(60000) to set a 60-second TTL.
Use `import koaCash from 'koa-cash'` or dynamic import `const koaCash = (await import('koa-cash')).default`.Ensure app.use(koaCash(...)) is called before any routes that use ctx.cashed(). Check that import/require is correct.
This is expected behavior. Ensure your downstream middleware handles the case when ctx.cashed() returns false.
No dependency data recorded yet.