README
fastify-disablecache
Fastify plugin to disable client-side caching
Intro
Inspired by nocache, the fastify-disablecache
plugin sets the following response headers and values to disable client-side caching:
Surrogate-Control: no-store
Cache-Control: no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
You can read more about these response headers on MDN here.
This plugin was created out of a need for an easy way to disable client-side caching for data received from backend APIs at Yeovil District Hospital NHS Foundation Trust. This ensures patient data is always current when called by applications.
Installation
Install using npm
:
npm install fastify-disablecache
Or yarn
:
yarn add fastify-disablecache
fastify-disablecache's test scripts use npm commands.
Example Usage
const Fastify = require("fastify");
const disableCache = require("fastify-disablecache");
const server = Fastify();
server.register(disableCache);
server.get("/", (req, res) => {
res.send("ok");
});
server.listen(3000);
Contributing
Contributions are welcome, and any help is greatly appreciated!
See CONTRIBUTING.md for details on how to get started. Please adhere to this project's Code of Conduct when contributing.
Acknowledgements
- Evan Hahn - nocache developer
- Matteo Collina - Optimisation suggestions
License
fastify-disablecache
is licensed under the MIT license.