A persistent HTTP ETag cache backed by LevelDB for Node.js. Current stable version is 2.1.17. It uses levelup and leveldown (or any abstract-leveldown-compatible store) to persist ETags and response bodies, enabling conditional requests (If-None-Match) and caching of fetch responses. It reconstructs Response-like objects when a cached entry matches. Key differentiators: direct integration with fetch API responses, simple key-value design (URL→ETag and ETag→body), and support for custom LevelDB instances. Release cadence is irregular as a side project.
npm install etag-cache-leveldbNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a LevelDB-backed ETag cache, storing a response, adding conditional headers, and loading a cached response on 304.
Clone the response before storing if you intend to read its body elsewhere: response.clone()
Pass a mutable headers object (e.g., new Headers() or a plain object).
Ensure you create a separate LevelDB instance per cache instance.
Always call levelup(leveldown(path)) before passing to ETagCacheLevelDB.
Check response status 304 or use addHeaders() first. Ensure response.headers.get('ETag') is present.const db = levelup(leveldown('/path'));Check that the response has an ETag header and that storeResponse() was called earlier for the same URL.
Ensure headers parameter is an object (e.g., new Headers() or {}).