{"id":15688349,"url":"https://github.com/fdawgs/fastify-disablecache","last_synced_at":"2025-04-16T03:48:26.654Z","repository":{"id":39199955,"uuid":"328696355","full_name":"Fdawgs/fastify-disablecache","owner":"Fdawgs","description":"Fastify plugin to disable client-side caching","archived":false,"fork":false,"pushed_at":"2025-03-21T15:15:12.000Z","size":804,"stargazers_count":9,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T04:51:09.587Z","etag":null,"topics":["cache","disable","disablecache","expires","fastify","headers","nocache","nodejs","plugin","pragma","surrogate"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/fastify-disablecache","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/Fdawgs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"Fdawgs"}},"created_at":"2021-01-11T14:49:13.000Z","updated_at":"2025-03-21T15:14:14.000Z","dependencies_parsed_at":"2022-08-09T12:34:41.014Z","dependency_job_id":"8de41fe1-3c4f-434e-a101-3366144419ed","html_url":"https://github.com/Fdawgs/fastify-disablecache","commit_stats":{"total_commits":450,"total_committers":5,"mean_commits":90.0,"dds":"0.49777777777777776","last_synced_commit":"50bd691d9cda649a96d5648aa8fc0c38e563f25a"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdawgs%2Ffastify-disablecache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdawgs%2Ffastify-disablecache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdawgs%2Ffastify-disablecache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdawgs%2Ffastify-disablecache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fdawgs","download_url":"https://codeload.github.com/Fdawgs/fastify-disablecache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249192417,"owners_count":21227784,"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":["cache","disable","disablecache","expires","fastify","headers","nocache","nodejs","plugin","pragma","surrogate"],"created_at":"2024-10-03T17:58:25.219Z","updated_at":"2025-04-16T03:48:26.635Z","avatar_url":"https://github.com/Fdawgs.png","language":"JavaScript","readme":"# fastify-disablecache\n\n[![GitHub Release](https://img.shields.io/github/release/Fdawgs/fastify-disablecache.svg)](https://github.com/Fdawgs/fastify-disablecache/releases/latest/)\n[![npm version](https://img.shields.io/npm/v/fastify-disablecache)](https://npmjs.com/package/fastify-disablecache)\n[![CI](https://github.com/Fdawgs/fastify-disablecache/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Fdawgs/fastify-disablecache/actions/workflows/ci.yml)\n[![Coverage status](https://coveralls.io/repos/github/Fdawgs/fastify-disablecache/badge.svg?branch=main)](https://coveralls.io/github/Fdawgs/fastify-disablecache?branch=main)\n[![code style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat)](https://github.com/prettier/prettier)\n\n\u003e Fastify plugin to disable client-side caching\n\n## Overview\n\nInspired by [nocache](https://github.com/helmetjs/nocache), the `fastify-disablecache` plugin sets the following response headers and values to disable client-side caching:\n\n```\nCache-Control: no-store, max-age=0, must-revalidate\nExpires: 0\nPragma: no-cache\nSurrogate-Control: no-store\n```\n\nThis plugin was created out of a need for an easy way to disable client-side caching for data received from backend APIs. This ensures data is always current when called by applications.\n\n### Why these headers?\n\n- `Cache-Control` - Primary response header for configuring cache controls [since HTTP/1.1](https://httpwg.org/specs/rfc7234.html#header.cache-control); whilst `no-store` is the directive to disable caching, clients such as [Internet Explorer](https://learn.microsoft.com/en-us/troubleshoot/developer/browsers/connectivity-navigation/how-to-prevent-caching#the-cache-control-header) did not use it, thus the addition of `max-age=0, must-revalidate`\n- `Expires` - Included for backwards compatibility with [HTTP/1.0 caches](https://w3.org/Protocols/HTTP/1.0/spec.html#Expires)\n- `Pragma` - Included for backwards compatibility with [HTTP/1.0 caches](https://w3.org/Protocols/HTTP/1.0/spec.html#Pragma), is [used by Internet Explorer](https://docs.microsoft.com/en-us/troubleshoot/developer/browsers/connectivity-navigation/how-to-prevent-caching#the-pragma-no-cache-header)\n- `Surrogate-Control` - Not a standardised response header but is [used by CDNs and reverse proxies](https://w3.org/TR/edge-arch/) for cache control\n\n## Installation\n\nInstall using `npm`:\n\n```bash\nnpm i fastify-disablecache\n```\n\nFor Fastify v4.x support, use `fastify-disablecache@3.1.9`.\n\n## Example usage\n\n```js\nconst Fastify = require(\"fastify\");\nconst disableCache = require(\"fastify-disablecache\");\n\nconst server = Fastify();\nserver.register(disableCache);\n\nserver.get(\"/\", (_req, res) =\u003e {\n\tres.send(\"ok\");\n});\n\nserver.listen(3000, (err) =\u003e {\n\tif (err) throw err;\n\tconsole.log(\"Server listening on 3000\");\n});\n```\n\n## Contributing\n\nContributions are welcome, and any help is greatly appreciated!\n\nSee [the contributing guide](https://github.com/Fdawgs/.github/blob/main/CONTRIBUTING.md) for details on how to get started.\nPlease adhere to this project's [Code of Conduct](https://github.com/Fdawgs/.github/blob/main/CODE_OF_CONDUCT.md) when contributing.\n\n## Acknowledgements\n\n- [**Aras Abbasi**](https://github.com/uzlopak) - TypeScript support\n- [**Evan Hahn**](https://github.com/EvanHahn) - [nocache](https://github.com/helmetjs/nocache) developer\n- [**Matteo Collina**](https://github.com/mcollina) - Optimisation suggestions\n\n## License\n\n`fastify-disablecache` is licensed under the [MIT](./LICENSE) license.\n","funding_links":["https://github.com/sponsors/Fdawgs"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdawgs%2Ffastify-disablecache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffdawgs%2Ffastify-disablecache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdawgs%2Ffastify-disablecache/lists"}