githubEdit

etag

NPM Versionarrow-up-right NPM Downloadsarrow-up-right Node.js Versionarrow-up-right Build Statusarrow-up-right Test Coveragearrow-up-right

Create simple HTTP ETags

This module generates HTTP ETags (as defined in RFC 7232) for use in HTTP responses.

Installation

This is a Node.jsarrow-up-right module available through the npm registryarrow-up-right. Installation is done using the npm install commandarrow-up-right:

$ npm install etag

API

var etag = require('etag')

etag(entity, [options])

Generate a strong ETag for the given entity. This should be the complete body of the entity. Strings, Buffers, and fs.Stats are accepted. By default, a strong ETag is generated except for fs.Stats, which will generate a weak ETag (this can be overwritten by options.weak).

res.setHeader('ETag', etag(body))

Options

etag accepts these properties in the options object.

weak

Specifies if the generated ETag will include the weak validator mark (that is, the leading W/). The actual entity tag is the same. The default value is false, unless the entity is fs.Stats, in which case it is true.

Testing

Benchmark

License

MITarrow-up-right

Last updated