`vary` is a focused Node.js utility library designed for manipulating the HTTP `Vary` response header. It provides a simple API to append fields to the `Vary` header of a Node.js `http.ServerResponse` object or directly to an existing `Vary` header string. Currently at version 1.1.2, the package maintains a stable and slow release cadence, primarily focusing on performance improvements and input validation rather than frequent feature additions. Its key differentiator is its singular purpose, offering a reliable and minimal solution for ensuring correct cache behavior when content varies based on request headers, without introducing additional HTTP framework overhead. It is a foundational utility used by many HTTP servers and middleware in the Node.js ecosystem.
npm install varyVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `vary(res, field)` to add a field to the Vary header of an HTTP response and `vary.append(header, field)` to manipulate a header string.
Ensure all `field` arguments passed to `vary(res, field)` or `vary.append(header, field)` conform to valid HTTP header field name syntax.
Always use `const vary = require('vary')` to import the module in both JavaScript and TypeScript projects (or configure TypeScript's `esModuleInterop` and `allowSyntheticDefaultImports` if you prefer `import` syntax).Understand `vary`'s behavior: it's designed to ensure a field is *present* in the `Vary` header without duplicating it or altering its existing order if already present. For complete control over header order, manipulate the string directly or use `vary.append` with an initial empty string.
Change the import statement to `const vary = require('vary')`.Ensure the `field` argument is a non-empty string representing a valid HTTP header field name (e.g., 'User-Agent', 'Accept-Encoding'). Refer to RFC 7231 for valid field name syntax.
No dependency data recorded yet.