Registry / web-framework / connect-cachify

connect-cachify

JSON →
library0.0.17jsnpmunverified

Connect/Express middleware for browser cache optimization via asset fingerprinting and concatenation. Current version 0.0.17 (unmaintained). Provides `cachify.setup` middleware and view helpers (`cachify_js`, `cachify_css`) that rewrite asset URLs to include a content hash, allowing far-future Expires headers and transparent fallback to individual scripts in development. Unlike connect-assets, it focuses solely on HTTP caching headers and URL rewriting without compilation. No release cadence; last published in 2013. Node.js >=0.4.7 required.

npm install connect-cachify
INSTALL
IMPORT
SIG · CONNECT-CACHIFY
C
connect-cachify
web-frameworkjavascriptv0.0.17
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.

default
import cachify from 'connect-cachify'
const { setup } = require('connect-cachify')
Package exports a single function that is also the `setup` method. ESM default import works in Node >=12.
setup
const { setup } = require('connect-cachify');
import setup from 'connect-cachify/setup';
CommonJS destructuring works; no separate `/setup` module exists.
cachify_js
app.locals.cachify_js = require('connect-cachify').cachify_js;
import { cachify_js } from 'connect-cachify';
View helpers are not exported; they are added to the request/response by the middleware. Use `cachify.setup` to make them available in templates.

Shows Express app with cachify middleware, asset map, and view helper injection.

const express = require('express'); const cachify = require('connect-cachify'); const app = express(); const assets = { '/js/bundle.min.js': ['/js/a.js', '/js/b.js'] }; app.use(cachify.setup(assets, { root: __dirname + '/public', production: process.env.NODE_ENV === 'production' })); app.use(express.static(__dirname + '/public')); app.set('view engine', 'ejs'); app.get('/', function(req, res) { res.render('index', { cachify_js: req.cachify_js, cachify_css: req.cachify_css }); }); app.listen(3000);
Debug
Known issues
deprecatedPackage has not been updated since 2013 and is incompatible with modern Express 4+ middleware pattern (no error middleware, deprecated `res.redirect` calls).
fix
Migrate to express-cachebuster or custom middleware with `etag` and `last-modified` handling.
affects: >=0.0.17
breakingThe `cachify.setup` middleware must be placed before `express.static` or other response-sending middleware, otherwise assets will be served without fingerprinting.
fix
Ensure `app.use(cachify.setup(...))` is called before `app.use(express.static(...))`.
affects: >=0.0.1
gotchaView helpers `cachify_js` and `cachify_css` are attached to `req` and `res` objects, not `app.locals`. In Express 4, you must manually pass them to templates via `res.locals`.
fix
Use middleware: `app.use(function(req, res, next) { res.locals.cachify_js = req.cachify_js; res.locals.cachify_css = req.cachify_css; next(); });`
affects: >=0.0.1
deprecatedThe `url_to_paths` option uses absolute filesystem paths; in production, use relative paths to avoid portability issues.
fix
Set `root` option and use relative paths in assets map instead of `url_to_paths`.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'connect-cachify'
Package not installed or missing from node_modules.
fix
Run `npm install connect-cachify` and ensure it's in your `package.json` dependencies.
TypeError: cachify.setup is not a function
Importing the module incorrectly (e.g., using default import when CommonJS required).
fix
Use `const cachify = require('connect-cachify');` and then `cachify.setup(...)`.
ReferenceError: cachify_js is not defined
View helper not available in template because middleware hasn't been applied or locals not set.
fix
Ensure `app.use(cachify.setup(...))` is called before any route that renders templates, and that `res.locals.cachify_js` is set.
Upgrade
Version history
0.0.17latest on npm
Audit
Dependencies
connectoptionalpeer dependency for Connect middleware compatibility (Express 2/3/4). Not listed as peer but used as middleware.
Agent activity
12 hits · last 30 days
node
10
Amazon
1
OpenAI (training)
1
Resources
connect-cachify — npm install connect-cachify · libregistry