The `etag` package is a minimalist, RFC 7232-compliant utility for generating HTTP ETags in Node.js applications. It currently maintains a stable version 1.8.1 and has a low release cadence, reflecting its maturity and focused scope. The library supports generating strong ETags for strings and `Buffer`s, and weak ETags by default for `fs.Stats` objects, with an option to override this behavior. Key differentiators include its strict adherence to the HTTP ETag specification, performance optimization for various entity sizes, and a history of robust integration within the `jshttp` ecosystem, often used by popular HTTP frameworks like Express. It prioritizes correctness and efficiency in ETag calculation, having evolved through several hashing algorithm updates to improve security and performance.
npm install etagVerified import paths — ran on the pinned version, not inferred.
Demonstrates generating strong and weak ETags for string and Buffer entities, illustrating typical usage patterns in Node.js.
Be aware that existing client caches relying on pre-1.8.0 ETags will likely become stale. If strict ETag consistency across deployments or upgrades is critical, consider implementing cache-busting strategies or re-evaluating caching policies.
Similar to the `v1.8.0` change, this also impacts ETag values. Ensure client caches are appropriately handled or invalidated if upgrading from versions prior to 1.7.0. Note that the MD5 algorithm used in this range was later updated to SHA1 in `v1.8.0`.
Always pass `{ weak: true }` or `{ weak: false }` to the `etag()` function if you need to override the default strong/weak behavior for specific entity types or to ensure consistent behavior.Ensure the first argument passed to `etag()` is a `string`, a `Buffer` instance, or an `fs.Stats` object (or a compatible mock object mimicking properties like `mtime`, `size`, `ino`).
To guarantee consistent ETag generation, ensure that the `etag` package version is locked and identical across all deployment environments. Use package manager commands like `npm ci` or `yarn install --frozen-lockfile` to enforce exact dependency versions.
No dependency data recorded yet.