Installations
npm install connect-cachify-static
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>= 20.1.0
Node Version
20.8.1
NPM Version
10.1.0
Score
67.6
Supply Chain
98.7
Quality
75.8
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (99.02%)
Makefile (0.98%)
Developer
pirxpilot
Download Statistics
Total Downloads
60,668
Last Day
3
Last Week
37
Last Month
222
Last Year
2,762
GitHub Statistics
4 Stars
80 Commits
4 Watching
2 Branches
2 Contributors
Bundle Size
10.41 kB
Minified
4.08 kB
Minified + Gzipped
Package Meta Information
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
Total Downloads
Cumulative downloads
Total Downloads
60,668
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Dev Dependencies
4
connect-cachify-static
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.
Installation
$ npm install connect-cachify-static
Options
match
- regular expression that determines which files inroot
will be cachified, if omitted the usual suspects are included.js
,.css
,.png
,.jpg
, and.gif
control_headers
- if truthy, the middleware will stripETag
andLast-Modified
headers from the responseformat
- function that creates cachified version of the URL - allowed values are'path'
,'name'
, or the function that takespath
andhash
and creates cachified version of the file URL
API
cachify
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 support
It 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
Usage
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'))
License
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
- Info: project has a license file: License:0
- Info: FSF or OSI recognized license: MIT License: License:0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
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
- Warn: no topLevel permission defined: .github/workflows/check.yaml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/check.yaml:7: update your workflow using https://app.stepsecurity.io/secureworkflow/pirxpilot/connect-cachify-static/check.yaml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/check.yaml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/pirxpilot/connect-cachify-static/check.yaml/main?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Score
3.4
/10
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