From f8ad7f217c6deec22f0a7c34b07f62cb8248efdc Mon Sep 17 00:00:00 2001 From: dickeyxxx Date: Tue, 5 May 2015 11:21:55 -0700 Subject: [PATCH] added cache_max_age option --- conf/full.yaml | 2 ++ lib/index-api.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/conf/full.yaml b/conf/full.yaml index b8c34418..c701de68 100644 --- a/conf/full.yaml +++ b/conf/full.yaml @@ -125,3 +125,5 @@ logs: # and the highest semver is placed instead. #ignore_latest_tag: false +# Enable a Cache-Control max-age header +#cache_max_size: 600 diff --git a/lib/index-api.js b/lib/index-api.js index 58aa50ef..fd8bfdc5 100644 --- a/lib/index-api.js +++ b/lib/index-api.js @@ -52,6 +52,10 @@ module.exports = function(config, auth, storage) { if (err) return next(err) info = Utils.filter_tarball_urls(info, req, config) + if (config.cache_max_age) { + res.header('Cache-Control', 'public, max-age=' + config.cache_max_age) + } + var version = req.params.version if (!version) return next(info)