https://github.com/mingchen/node-nocache
Add nocache headers to node response
https://github.com/mingchen/node-nocache
express express-middleware nocache node
Last synced: 4 months ago
JSON representation
Add nocache headers to node response
- Host: GitHub
- URL: https://github.com/mingchen/node-nocache
- Owner: mingchen
- License: mit
- Created: 2017-03-01T22:01:45.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-23T12:18:04.000Z (about 6 years ago)
- Last Synced: 2025-10-07T01:22:28.237Z (9 months ago)
- Topics: express, express-middleware, nocache, node
- Language: JavaScript
- Size: 200 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
node-nocache
============
[](https://travis-ci.org/mingchen/node-nocache)
[](https://greenkeeper.io/)
[](https://nodei.co/npm/node-nocache/)
## Introduction
A node `express` middleware which add no-cache related headers for all the express response to disable caches.
It is useful for REST API response, add no-cache headers to avoid browsers cache request response.
The following headers are added to response header:
Cache-Control: no-cache, no-store, must-revalidate
Expires: -1
Pragma: no-cache
## Install
npm install node-nocache
## Usage
let nocache = require('node-nocache');
app.use(nocache);
or use you can only add no-cache headers to specific requests with `router`:
router.all('*', require('node-nocache'));
or
let nocache = require('node-nocache');
router.get('/api/foo', nocache, function (req, res, next) {
...
});
Checkout `test/nocache_test.js` for example usages.
## License
MIT