Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@fastify/etag
Advanced tools
A plugin for Fastify that automatically generates HTTP ETags according to RFC2616-sec13.
The plugin can optionally send a 304 status code when an ETag matches the if-none-match header.
npm i @fastify/etag
'use strict'
const Fastify = require('fastify')
const Etag = require('@fastify/etag')
const app = Fastify()
app.register(Etag)
app.get('/', async (req, reply) => {
return { hello: 'world' }
})
app.get('/manual-etag', async (req, reply) => {
// This will disable automatic ETag generation
// It will still return a 304 if the ETag matches
reply.header('etag', '"foobar"')
return 'world'
})
app.listen(3000)
algorithm
: all hashing algorithms the Node.js crypto
module supports, and 'fnv1a'
. Default: 'sha1'
.
weak
: generates weak ETags by default. Default: false
.
By default, the plugin sends a 304 status code when the ETag is equal to the Etag specified by the if-none-match request header.
This is often the desired behaviour, but can be disabled by setting replyWith304: false
.
The fnv1a logic was forked from https://github.com/sindresorhus/fnv1a and adapted to support buffers.
Generating an etag will always be slower than not generating an etag. The generation speed also depends on the payload size and type (buffer or string):
'fnv1a'
'md5'
'sha1'
(default)MIT
FAQs
Automatically generate etags for HTTP responses, for Fastify
The npm package @fastify/etag receives a total of 10,798 weekly downloads. As such, @fastify/etag popularity was classified as popular.
We found that @fastify/etag demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.