All Projects → fastify → fastify-etag

fastify / fastify-etag

Licence: MIT license
Automatically generate etags for HTTP responses, for Fastify

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to fastify-etag

fastify-axios
Add axios http client to your fastify instance
Stars: ✭ 28 (-54.1%)
Mutual labels:  fastify, fastify-plugin
fastify-postgres
Fastify PostgreSQL connection plugin
Stars: ✭ 144 (+136.07%)
Mutual labels:  fastify, fastify-plugin
fastify-cron
Run cron jobs alongside your Fastify server 👷
Stars: ✭ 32 (-47.54%)
Mutual labels:  fastify, fastify-plugin
fastify-webpack-hmr
Webpack hot module reloading for Fastify
Stars: ✭ 29 (-52.46%)
Mutual labels:  fastify, fastify-plugin
fastify-env
Fastify plugin to check environment variables
Stars: ✭ 129 (+111.48%)
Mutual labels:  fastify, fastify-plugin
create-fastify-app
An utility that help you to generate or add plugin to your Fastify project
Stars: ✭ 53 (-13.11%)
Mutual labels:  fastify, fastify-plugin
fastify-hasura
A Fastify plugin to have fun with Hasura.
Stars: ✭ 30 (-50.82%)
Mutual labels:  fastify, fastify-plugin
fastify-openapi-glue
A plugin for Fastify to autogenerate a configuration based on a OpenApi(v2/v3) specification.
Stars: ✭ 94 (+54.1%)
Mutual labels:  fastify, fastify-plugin
fastify-awilix
Dependency injection support for fastify
Stars: ✭ 52 (-14.75%)
Mutual labels:  fastify, fastify-plugin
fastify-loader
The route loader for the cool kids!
Stars: ✭ 17 (-72.13%)
Mutual labels:  fastify, fastify-plugin
fastify-caching
A Fastify plugin to facilitate working with cache headers
Stars: ✭ 123 (+101.64%)
Mutual labels:  fastify, fastify-plugin
fastify-csrf
A fastify csrf plugin.
Stars: ✭ 88 (+44.26%)
Mutual labels:  fastify, fastify-plugin
fastify-autoroutes
fastest way to map directories to URLs in fastify
Stars: ✭ 70 (+14.75%)
Mutual labels:  fastify, fastify-plugin
fastify-vite
This plugin lets you load a Vite client application and set it up for Server-Side Rendering (SSR) with Fastify.
Stars: ✭ 497 (+714.75%)
Mutual labels:  fastify, fastify-plugin
fastify-file-upload
Fastify plugin for uploading files
Stars: ✭ 68 (+11.48%)
Mutual labels:  fastify, fastify-plugin
fastify-accepts
Add accepts parser to fastify
Stars: ✭ 51 (-16.39%)
Mutual labels:  fastify, fastify-plugin
fastify-passport
Use passport strategies for authentication within a fastify application
Stars: ✭ 150 (+145.9%)
Mutual labels:  fastify, fastify-plugin
fastify-cors
Fastify CORS
Stars: ✭ 212 (+247.54%)
Mutual labels:  fastify, fastify-plugin
fastify-vue
A nuxt.js fastify plugin
Stars: ✭ 27 (-55.74%)
Mutual labels:  fastify, fastify-plugin
fastify-leveldb
Plugin to share a common LevelDB connection across Fastify.
Stars: ✭ 19 (-68.85%)
Mutual labels:  fastify, fastify-plugin

@fastify/etag

CI NPM version js-standard-style

A plugin for Fastify that automatically generates HTTP ETags and returns 304 when needed, according to RFC2616-sec13.

Install

npm i @fastify/etag

Example

'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)

Plugin Options

  • algorithm: all hashing algorithm that Node.js support, and 'fnv1a'. Default: 'fnv1a'.

  • weak: generates weak ETags by default. Default: false.

Acknowledgements

The fnv1a logic was forked from https://github.com/sindresorhus/fnv1a and adapted to support buffers.

Benchmarks

  • md5 algorithm: 29679 req/s (median)
  • sha1 algorithm: 25935 req/s (median)
  • fnv1a algorithm: 42943 req/s (median)
  • No ETag generation: 45471 req/s (median)

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].