From 1d87543d9ad51f3c040358dfad4484caa582ce8d Mon Sep 17 00:00:00 2001 From: Nandan Sridhar Date: Wed, 14 Nov 2018 20:44:18 -0800 Subject: [PATCH] fix no cache condition --- apikeys/index.js | 2 +- oauth/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apikeys/index.js b/apikeys/index.js index 58ca3c8..8730579 100644 --- a/apikeys/index.js +++ b/apikeys/index.js @@ -66,7 +66,7 @@ module.exports.init = function(config, logger, stats) { } var exchangeApiKeyForToken = function(req, res, next, config, logger, stats, middleware, apiKey) { - var cacheControl = req.headers["cache-control"]; + var cacheControl = req.headers["cache-control"] || 'no-control'; if (cacheKey || (cacheControl && cacheControl.indexOf("no-cache") < 0)) { // caching is allowed cache.read(apiKey, function(err, value) { if (value) { diff --git a/oauth/index.js b/oauth/index.js index ee6264e..03e175d 100644 --- a/oauth/index.js +++ b/oauth/index.js @@ -119,7 +119,7 @@ module.exports.init = function(config, logger, stats) { } var exchangeApiKeyForToken = function(req, res, next, config, logger, stats, middleware, apiKey) { - var cacheControl = req.headers['cache-control']; + var cacheControl = req.headers['cache-control'] || 'no-cache'; if (cacheKey || (!cacheControl || (cacheControl && cacheControl.indexOf('no-cache') < 0))) { // caching is allowed cache.read(apiKey, function(err, value) { if (value) { @@ -445,4 +445,4 @@ function sendError(req, res, next, logger, stats, code, message) { stats.incrementStatusCount(res.statusCode); next(code, message); return code; -} \ No newline at end of file +}