Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add no-cache header.

  • Loading branch information...
commit 77eab75520b266f1d024f9255c1cc2559030c6b2 1 parent ec0608e
Brian J Brennan brianloveswords authored
Showing with 13 additions and 0 deletions.
  1. +3 −0  app.js
  2. +10 −0 middleware.js
3  app.js
View
@@ -32,6 +32,9 @@ app.configure(function () {
app.use(express.static(path.join(__dirname, 'public')));
app.use(middleware.csrf({whitelist: ['/v1/*']}));
app.use(middleware.cors({whitelist: ['/v1/*']}));
+ app.use(middleware.noCache({
+ whitelist: ['/badge/assertion/*']
+ }));
app.use(user.requireAuth({
whitelist: [
'/login',
10 middleware.js
View
@@ -33,6 +33,16 @@ exports.cors = function cors(options) {
};
};
+exports.noCache = function noCache(options) {
+ options = options || {};
+ var whitelist = parseWhitelist(options.whitelist);
+ return function (req, res, next) {
+ if (!isExempt(whitelist, req.url))
+ res.header("Cache-Control", "no-cache");
+ return next();
+ };
+};
+
/** Adapted from connect/lib/middleware/csrf.js */
exports.csrf = function csrf(options) {
options = options || {}
Please sign in to comment.
Something went wrong with that request. Please try again.