Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Repository files navigation

node-nocache

Build Status Greenkeeper badge

NPM

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

About

Add nocache headers to node response

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.