Skip to content

Commit

Permalink
adds cache-control max-age setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Whitley committed Nov 18, 2016
1 parent ddea3ef commit ed64140
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/apicache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ed64140

Please sign in to comment.