Gathering detailed insights and metrics for connect-cachify-static
Gathering detailed insights and metrics for connect-cachify-static
Gathering detailed insights and metrics for connect-cachify-static
Gathering detailed insights and metrics for connect-cachify-static
static (simpler and faster) variant of connect-cachify middleware
npm install connect-cachify-static
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (98.37%)
Makefile (1.63%)
Total Downloads
61,535
Last Day
6
Last Week
28
Last Month
147
Last Year
2,524
MIT License
4 Stars
89 Commits
3 Watchers
2 Branches
2 Contributors
Updated on Mar 07, 2025
Minified
Minified + Gzipped
Latest Version
4.0.1
Package Id
connect-cachify-static@4.0.1
Unpacked Size
10.89 kB
Size
4.60 kB
File Count
8
NPM Version
10.9.0
Node Version
22.12.0
Published on
Mar 07, 2025
Cumulative downloads
Total Downloads
Last Day
20%
6
Compared to previous day
Last Week
-56.9%
28
Compared to previous week
Last Month
-40.7%
147
Compared to previous month
Last Year
-25.4%
2,524
Compared to previous year
3
3
static (simpler and faster) variant of connect-cachify middleware
Adds Cache-Control: max-age=31536000
header to all requests with 'cachified' prefix. Prefix is
based on the file content and calculated for all files during application startup (which means that
it won't handle dynamically generated files).
If you reference cachifieable resources from CSS files you probably also want to use postcss-cachify.
$ npm install connect-cachify-static
match
- regular expression that determines which files in root
will be cachified, if omitted
the usual suspects are included .js
, .css
, .png
, .jpg
, and .gif
control_headers
- if truthy, the middleware will strip ETag
and Last-Modified
headers from the
responseformat
- function that creates cachified version of the URL - allowed values are 'path'
, 'name'
,
or the function that takes path
and hash
and creates cachified version of the file URLcachify
function is injected in res.locals and thus can be accessed from the template code.
cachify
and filter
can be also retrieved by calling await helpers()
on the initialized middleware instance
cachify(path, integrity)
path
- URL of the resource to be cachifiedintegrity
- optional - if truthy cachify will generate a tuple { path, integrity }
, which can
be used to format <script>
and <link>
elements with subresource integrity supportIt should be called when generating HTML, CSS etc., in order to create a 'cachified' URL for the
resource. cachify
will replace /path/to/the/file
with cachified version incorporating reasonably unique {prefix}
generated based on the file content.
The specific format of the cachified version depends on the format
parameter:
path
default
/path/to/the/file
-> /{prefix}/path/to/the/file
name
/path/to/the/file
-> /path/to/the/{prefix}- file
You can also pass a format function:
1// this is how default format is implemented 2function format(path, prefix) { 3 return '/' + prefix + path; 4} 5
Since using cachify
will make the browsers to cache the resource for approximately 1 year we need
to bust the cache whenever the resource content changes.
1head 2 //- styles 3 link(rel="stylesheet", href=cachify('/css/style.css'), media="screen") 4 link(rel="stylesheet", href=cachify('/css/print.css'), media="print") 5body 6 // can be used to pass cachified URLs to client scripts 7 #info(data-icon=cachify('/img/icon.png')) 8 //- scripts 9 script(src=cachify('/script/main.js'), defer) 10 11 //- scripts with SRI support 12 - var c = cachify('/script/main.js', true) 13 script(src=c.path, integrity=c.integrity, crossorigin='anonymous', defer) 14
filter(patter)
returns an array of cachified paths matching pattern
1var connect = require('connect'); 2var cachifyStatic = require('connect-cachify-static'); 3 4connect() 5 .use(cachifyStatic(__dirname + '/public'), { 6 match: /\.js$/ // only javascript files 7 }) 8// need static to actually serve the file 9connect() 10 .use(connect.static(__dirname + '/public'))
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
8 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 6
Reason
no SAST tool detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
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
Score
Last Scanned on 2025-05-05
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