🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

fastify-disablecache

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-disablecache

Fastify plugin to disable client-side caching

Source
npmnpm
Version
3.1.9
Version published
Weekly downloads
7.7K
-14.43%
Maintainers
1
Weekly downloads
 
Created
Source

fastify-disablecache

GitHub Release npm version Build status Coverage status code style: Prettier

Fastify plugin to disable client-side caching

Overview

Inspired by nocache, the fastify-disablecache plugin sets the following response headers and values to disable client-side caching:

Cache-Control: no-store, max-age=0, must-revalidate
Expires: 0
Pragma: no-cache
Surrogate-Control: no-store

This 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.

Why these headers?

Installation

Install using npm:

npm i fastify-disablecache

For Fastify v3.x support, use fastify-disablecache@2.0.8.

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, (err) => {
	if (err) throw err;
	console.log("Server listening on 3000");
});

Contributing

Contributions are welcome, and any help is greatly appreciated!

See the contributing guide for details on how to get started. Please adhere to this project's Code of Conduct when contributing.

Acknowledgements

License

fastify-disablecache is licensed under the MIT license.

Keywords

cache

FAQs

Package last updated on 25 Jan 2024

Did you know?

Socket

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.

Install

Related posts