Skip to content

Instantly share code, notes, and snippets.

@digitallysavvy
Created July 16, 2020 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitallysavvy/e371a2b03819d282948a85f613ba21d4 to your computer and use it in GitHub Desktop.
Save digitallysavvy/e371a2b03819d282948a85f613ba21d4 to your computer and use it in GitHub Desktop.
simple no cache function for use in an express server to force the browser to never cache the response, to ensure fresh response each time.
const nocache = (req, resp, next) => {
resp.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
resp.header('Expires', '-1');
resp.header('Pragma', 'no-cache');
next();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment