From ed64140184b26d1dee134f7ed2f7c4dded3c8764 Mon Sep 17 00:00:00 2001 From: Kevin Whitley Date: Fri, 18 Nov 2016 14:20:43 -0600 Subject: [PATCH] adds cache-control max-age setting --- src/apicache.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/apicache.js b/src/apicache.js index 5b8b3aa..b1a5ce6 100644 --- a/src/apicache.js +++ b/src/apicache.js @@ -107,6 +107,10 @@ function ApiCache() { res.__end = res.end res.end = function(content, encoding) { if (shouldCacheResponse(res)) { + res.header({ + 'cache-control': 'max-age=' + (duration / 1000).toFixed(0) + }) + addIndexEntries(key, req) var cacheObject = createCacheObject(res.statusCode, res._headers, content, encoding) cacheResponse(key, cacheObject, duration)