Registry / devops / koa-no-cache

koa-no-cache

JSON →
library2.0.0jsnpmunverified

Koa middleware to disable client-side caching for specified paths or content types. Version 2.0.0 is current; low maintenance, last updated 2018. Uses path-to-regexp for route matching and type-is for content type detection. Differentiators: lightweight, simple API with global or selective caching disablement.

npm install koa-no-cache
INSTALL
IMPORT
SIG · KOA-NO-CACHE
K
koa-no-cache
devopsjavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

noCache
import noCache from 'koa-no-cache'
const { default: noCache } = require('koa-no-cache')
ES module import is recommended; if using CommonJS, use `const noCache = require('koa-no-cache')`.
noCache
const noCache = require('koa-no-cache')
const { noCache } = require('koa-no-cache')
Default export, not a named export.

Creates a Koa app and applies no-cache headers for paths starting with /api/ and for JSON/HTML responses.

import Koa from 'koa'; import noCache from 'koa-no-cache'; const app = new Koa(); app.use(noCache({ paths: ['/api/(.*)'], types: ['json', 'html'] })); app.listen(3000); console.log('Server running on port 3000');
Debug
Known issues
gotchaThe `paths` option uses path-to-regexp syntax, not simple globs.
fix
Ensure path patterns follow path-to-regexp format, e.g., '/users/:id'.
affects: >=1.0.0
deprecatedPackage is no longer actively maintained; last update in 2018.
fix
Consider forking or using alternatives like koa-conditional-get or koa-etag.
affects: >=2.0.0
gotchaThe `types` option uses type-is module; ensure correct MIME types.
fix
Provide correct MIME types such as 'text/html', 'application/json'.
affects: >=1.0.0
gotchaMiddleware must be added after response body is set; otherwise headers may not apply.
fix
Place middleware after routes or other middleware that sets response content.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: noCache is not a function
Using named import '{ noCache }' instead of default import.
fix
Use 'import noCache from 'koa-no-cache'' or 'const noCache = require('koa-no-cache')'.
Cannot find module 'koa-no-cache'
Package not installed.
fix
Run 'npm install koa-no-cache'
noCache is not a function | Error: middleware must be a function
Passing an object without calling noCache() or incorrect import.
fix
Ensure you call noCache({...}) before passing to app.use().
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
koa-no-cache — npm install koa-no-cache · libregistry