Registry / testing / restify-etag-cache

restify-etag-cache

JSON →
library1.0.12jsnpmunverified

Automatic ETag-based caching middleware for Restify servers (v1.0.12, last updated 2017). Very low maintenance: no recent releases, few dependencies. Differentiator: simple drop-in middleware for restify that handles 304 responses without configuration beyond ignore lists and weak/strong ETag selection. Status: maintenance due to infrequent updates and lack of activity.

npm install restify-etag-cache
INSTALL
IMPORT
SIG · RESTIFY-ETAG-CACHE
R
restify-etag-cache
testingjavascriptv1.0.12
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
const restifyEtagCache = require('restify-etag-cache');
import restifyEtagCache from 'restify-etag-cache';
Package is CJS-only (no ESM), so require() is the only way. No named exports exist.

Creates a restify server, applies ETag cache middleware with route/URL ignore options, and defines a sample GET route.

const restify = require('restify'); const restifyEtagCache = require('restify-etag-cache'); const server = restify.createServer({ name: 'myapp', version: '1.0.0' }); const options = { ignore_routes: ['/some/route/to/ignore/:withParam'], ignore_urls: ['/some/specific/url/to/ignore'], weak: false }; server.use(restifyEtagCache(options)); server.get('/hello/:name', function(req, res, next) { res.send(200, { message: 'Hello ' + req.params.name }); return next(); }); server.listen(8080, function() { console.log('%s listening at %s', server.name, server.url); });
Debug
Known issues
deprecatedlodash dependency (v3.x) and old versions of restify may have security vulnerabilities.
fix
Review package.json and update lodash to 4.17.21+ manually; consider alternative caching solutions if security is critical.
affects: >=1.0.0
breakingThe options object uses `ignore_routes` and `ignore_urls` (underscore style) which may conflict with camelCase conventions in newer restify versions.
fix
No fix; the property names are hardcoded. Use underscore style as shown in documentation.
affects: >=1.0.0
gotchaThe weak ETag option can cause false positives (304 responses for semantically different content) if set to true.
fix
Set `weak: false` for strict comparison; be aware of the tradeoff.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'headers' of undefined
Middleware applied before server routes are defined, and no request object passed due to misconfiguration.
fix
Ensure server.use() is called before defining any routes, and that restify is properly initialized.
Error: ETag mismatch: expected "..." but got "..."
Weak ETag enabled and content changed slightly without affecting byte-for-byte representation.
fix
Set weak to false to force strong ETag comparison.
Upgrade
Version history
1.0.12latest on npm
Audit
Dependencies
restifyrequiredThis module is designed exclusively as middleware for restify servers and depends on restify's request/response objects.
Agent activity
3 hits · last 30 days
node
3
Resources
restify-etag-cache — npm install restify-etag-cache · libregistry