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
npm install connect-cachify-static
Typescript
Module System
Min. Node Version
Node Version
NPM Version
67.6
Supply Chain
98.7
Quality
75.8
Maintenance
100
Vulnerability
100
License
JavaScript (99.02%)
Makefile (0.98%)
Total Downloads
60,668
Last Day
3
Last Week
37
Last Month
222
Last Year
2,762
4 Stars
80 Commits
4 Watching
2 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
4.0.0
Package Id
connect-cachify-static@4.0.0
Unpacked Size
10.99 kB
Size
4.60 kB
File Count
8
NPM Version
10.1.0
Node Version
20.8.1
Publised On
16 Oct 2023
Cumulative downloads
Total Downloads
Last day
-90.3%
3
Compared to previous day
Last week
-31.5%
37
Compared to previous week
Last month
17.5%
222
Compared to previous month
Last year
-24.8%
2,762
Compared to previous year
3
4
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 dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/30 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
detected GitHub workflow tokens with excessive permissions
Details
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 2024-12-30
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