Skip to content

Commit

Permalink
Merge pull request #68 from Stx-Cld/patch-1
Browse files Browse the repository at this point in the history
Store API key in cache
  • Loading branch information
srinandan authored Nov 22, 2017
2 parents 6ac05dd + 22e5122 commit 1e12374
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions oauth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ module.exports.init = function(config, logger, stats) {

if (apiKey) {
var cacheControl = req.headers['cache-control'];
if (!cacheControl || (cacheControl && cacheControl.indexOf('no-cache') < 0)) { // caching is allowed
if (cacheKey || (!cacheControl || (cacheControl && cacheControl.indexOf('no-cache') < 0))) { // caching is allowed
// default to now (in seconds) + 30m if not set
decodedToken.exp = decodedToken.exp || +(((Date.now() / 1000) + 1800).toFixed(0));
apiKeyCache[apiKey] = decodedToken;
Expand Down Expand Up @@ -356,4 +356,4 @@ function sendError(req, res, next, logger, stats, code, message) {
stats.incrementStatusCount(res.statusCode);
next(code, message);
return code;
}
}

0 comments on commit 1e12374

Please sign in to comment.