Registry / devops / cache-control

cache-control

JSON →
library2.0.0jsnpmunverified

Express/Connect middleware for setting cache headers based on URL patterns using glob matching. Current version is 2.0.0, released in 2013 with infrequent updates. It allows mapping URL glob patterns to cache durations (in seconds), booleans for no caching, or custom Cache-Control header strings. Differentiators: simple glob-based configuration, minimal overhead; however, it is outdated and may have security issues.

npm install cache-control
INSTALL
IMPORT
SIG · CACHE-CONTROL
C
cache-control
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.

cache
var cache = require('cache-control')
import cache from 'cache-control'
Package is CommonJS only. ESM import will fail.
cache
var cache = require('cache-control')
const { cache } = require('cache-control')
exports a single function, not an object with named exports.
default
var cache = require('cache-control')
var cache = require('cache-control').default
No default export property exists; use require directly.

Sets cache headers for different URL patterns using globs, with values in seconds, boolean, or custom Cache-Control string.

var express = require('express'); var cache = require('cache-control'); var app = express(); app.use(cache({ '/index.html': 1000, '/none/**/*.html': false, '/private.html': 'private, max-age=300', '/**': 500 })); app.listen(3000);
Debug
Known issues
gotchaBoolean false disables caching via 'no-cache, no-store, must-revalidate' header
fix
Use false to disable caching; for custom headers, pass a string.
affects: >=1.0.0
gotchaGlob patterns are evaluated in order, first match wins
fix
Order options object from most specific to least specific.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: cache is not a function
Package not installed or incorrectly imported
fix
Run 'npm install cache-control --save' and use var cache = require('cache-control');
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
cache-control — npm install cache-control · libregistry