{"id":14969153,"url":"https://github.com/fastify/fastify-etag","last_synced_at":"2025-05-16T12:05:39.890Z","repository":{"id":35002597,"uuid":"194390318","full_name":"fastify/fastify-etag","owner":"fastify","description":"Automatically generate etags for HTTP responses, for Fastify","archived":false,"fork":false,"pushed_at":"2024-10-21T10:53:03.000Z","size":128,"stargazers_count":76,"open_issues_count":5,"forks_count":14,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-10-29T14:46:38.535Z","etag":null,"topics":["fastify","fastify-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fastify","open_collective":"fastify"}},"created_at":"2019-06-29T09:54:22.000Z","updated_at":"2024-10-21T10:53:01.000Z","dependencies_parsed_at":"2024-01-23T20:11:42.546Z","dependency_job_id":"8f940770-b3b5-45d3-93fd-96d58fd3c6b7","html_url":"https://github.com/fastify/fastify-etag","commit_stats":{"total_commits":140,"total_committers":24,"mean_commits":5.833333333333333,"dds":0.6285714285714286,"last_synced_commit":"729115aaf6a25c8da0ed9ba0e9288b31b9e20874"},"previous_names":["fastify/fastify-auto-etag"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-etag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-etag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-etag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-etag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastify","download_url":"https://codeload.github.com/fastify/fastify-etag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248544901,"owners_count":21122050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastify","fastify-plugin"],"created_at":"2024-09-24T13:41:14.296Z","updated_at":"2025-04-12T09:24:44.653Z","avatar_url":"https://github.com/fastify.png","language":"JavaScript","readme":"# @fastify/etag\n\n[![CI](https://github.com/fastify/fastify-etag/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/fastify-etag/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/@fastify/etag.svg?style=flat)](https://www.npmjs.com/package/@fastify/etag)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nA plugin for [Fastify](https://fastify.dev) that automatically generates HTTP ETags according to [RFC2616-sec13](https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html).\n\nThe plugin can optionally send a 304 status code when an ETag matches the if-none-match header.\n\n\n## Install\n\n```sh\nnpm i @fastify/etag\n```\n\n### Compatibility\n| Plugin version | Fastify version |\n| ---------------|-----------------|\n| `^6.x`         | `^5.x`          |\n| `^4.x`         | `^4.x`          |\n| `^3.x`         | `^3.x`          |\n| `^1.x`         | `^2.x`          |\n\n\nPlease note that if a Fastify version is out of support, then so are the corresponding versions of this plugin\nin the table above.\nSee [Fastify's LTS policy](https://github.com/fastify/fastify/blob/main/docs/Reference/LTS.md) for more details.\n\n## Example\n\n```js\n'use strict'\n\nconst Fastify = require('fastify')\nconst Etag = require('@fastify/etag')\n\nconst app = Fastify()\napp.register(Etag)\n\napp.get('/', async (req, reply) =\u003e {\n  return { hello: 'world' }\n})\n\napp.get('/manual-etag', async (req, reply) =\u003e {\n  // This will disable automatic ETag generation\n  // It will still return a 304 if the ETag matches\n  reply.header('etag', '\"foobar\"')\n  return 'world'\n})\n\napp.listen(3000)\n```\n\n## Plugin Options\n\n* `algorithm`: all hashing algorithms the Node.js [`crypto`](https://nodejs.org/api/crypto.html) module supports, and `'fnv1a'`. Default: `'sha1'`.\n\n* `weak`: generates weak ETags by default. Default: `false`.\n\n### Automatic 304 status codes\n\nBy default, the plugin sends a 304 status code when the ETag is equal to the Etag specified by the if-none-match request header.\n\nThis is often the desired behavior, but can be disabled by setting `replyWith304: false`.\n\n## Acknowledgments\n\nThe fnv1a logic was forked from https://github.com/sindresorhus/fnv1a and adapted to support buffers.\n\n## Benchmarks\n\nGenerating 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):\n\n* For very small payloads (\u003c 2 kb), use `'fnv1a'`\n* For buffers above 2 mb, use `'md5'`\n* In all other scenarios, use `'sha1'` (default)\n* YMMV, see [this issue](https://github.com/fastify/fastify-etag/issues/91) where other algorithms such as crc32 for small payloads and murmurhash3-wasm for big buffers have performed better than the mentioned recommendations\n* Any etag generation results in at least 10% less op/s (up to 50% less op/s for huge payloads)\n\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","funding_links":["https://github.com/sponsors/fastify","https://opencollective.com/fastify"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-etag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastify%2Ffastify-etag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-etag/lists"}