Gathering detailed insights and metrics for @kapouer/express-cache-response-directive
Gathering detailed insights and metrics for @kapouer/express-cache-response-directive
Gathering detailed insights and metrics for @kapouer/express-cache-response-directive
Gathering detailed insights and metrics for @kapouer/express-cache-response-directive
ExpressJS middleware that gives Response objects an intuitive .cacheControl method to set Cache-Control headers.
npm install @kapouer/express-cache-response-directive
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
7 Stars
28 Commits
5 Forks
2 Watchers
2 Branches
1 Contributors
Updated on Apr 10, 2020
Latest Version
2.1.0
Package Id
@kapouer/express-cache-response-directive@2.1.0
Unpacked Size
15.66 kB
Size
5.19 kB
File Count
6
NPM Version
9.2.0
Node Version
18.14.2
Published on
Oct 15, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
Middleware for ExpressJS that defines a cacheControl
method to set Cache-Control
headers.
This middleware doesn't define legacy Expires headers. For compatibility with old HTTP/1.0 agents combine it with express-legacy-expires.
1npm install express-cache-response-directive
1const cacheResponseDirective = require('express-cache-response-directive');
1app.use(cacheResponseDirective());
1app.get('/', function(req, res, next) { 2 res.cacheControl({maxAge: 300}); 3 // ... 4});
The method added by the middleware accepts an optional string pattern and an object of Cache-Control options. Both are optional but at least one of them should be specified.
See the HTTP/1.1 Standard's Cache-Control sections for information on the usage of Cache-Control directives.
String patterns are defined for simple directives so you can simply write res.cacheControl("public");
instead of having to always write res.cacheControl({'public': true});
. Patterns can be combined with options res.cacheControl("public", {mustRevalidate: true});
.
1res.cacheControl("public"); 2// Cache-Control: public
1res.cacheControl("private"); 2// Cache-Control: private
1res.cacheControl("no-cache"); 2// Cache-Control: no-cache
1res.cacheControl("no-store"); 2// Cache-Control: no-cache, no-store
Each Cache-Control response directive defined in HTTP/1.1 has an option that can be defined.
true
for the normal non-field directive and for the with field-name directive accept either a string or an array of strings for the field names.The public, private, no-cache, and no-store directives are exclusive only one may be specified. With the exception that no-cache and no-store may be defined together.
1res.cacheControl({'public': true}); 2// Cache-Control: public
1res.cacheControl({'private': true}); 2// Cache-Control: private
1res.cacheControl({'private': "X-Private"}); 2// Cache-Control: private="X-Private"
1res.cacheControl({'private': ["X-Private-1", "X-Private-2"]}); 2// Cache-Control: private="X-Private-1, X-Private-2"
1res.cacheControl({'no-cache': true});
2res.cacheControl({noCache: true});
3// Cache-Control: no-cache
1res.cacheControl({noCache: "X-Uncached"}); 2// Cache-Control: no-cache="X-Uncached"
1res.cacheControl({noCache: ["X-Uncached-1", "X-Uncached-2"]}); 2// Cache-Control: no-cache="X-Uncached-1, X-Uncached-2"
1res.cacheControl({'no-store': true});
2res.cacheControl({noStore: true});
3// Cache-Control: no-cache, no-store
no-store
also implies no-cache
because some browsers have begun treating no-cache the same way they treat no-store.1res.cacheControl({'max-age': 300});
2res.cacheControl({maxAge: 300});
3res.cacheControl({maxAge: "5min"});
4// Cache-Control: public, max-age=300
max-age
implies public if none of private, no-cache, or no-store is defined, so you can define it alone.1res.cacheControl({'s-maxage': 300});
2res.cacheControl({sMaxage: 300});
3res.cacheControl({sMaxAge: 300});
4// Cache-Control: public, s-maxage=300
s-maxage
supports sMaxAge
in addition to the standard camel-case conversion sMaxage
due to the potential confusion of the max-age
to maxAge
conversion.1res.cacheControl({'must-revalidate': true});
2res.cacheControl({mustRevalidate: true});
3// Cache-Control: must-revalidate
1res.cacheControl({'proxy-revalidate': true});
2res.cacheControl({proxyRevalidate: true});
3// Cache-Control: proxy-revalidate
1res.cacheControl({noTransform: true});
2res.cacheControl({'no-transform': true});
3// Cache-Control: no-transform
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 1/27 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More