From e477cb42a77ab74759163118e935d5f6cfe98a2f Mon Sep 17 00:00:00 2001 From: Thaddee Tyl Date: Sat, 29 Aug 2015 14:00:33 +0200 Subject: [PATCH] Reuse sent cache-control for /badge/ --- server.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index b6e5eb7..085dcf3 100644 --- a/server.js +++ b/server.js @@ -4125,9 +4125,13 @@ function(data, match, end, ask) { incrMonthlyAnalytics(analytics.rawFlatSquareMonthly); } - // Cache management - the badge is constant. - var cacheDuration = (3600*24*1)|0; // 1 day. - ask.res.setHeader('Cache-Control', 'public, max-age=' + cacheDuration); + if (ask.req.headers['cache-control']) { + ask.res.setHeader('Cache-Control', ask.req.headers['cache-control']); + } else { + // Cache management - the badge is constant. + var cacheDuration = (3600*24*1)|0; // 1 day. + ask.res.setHeader('Cache-Control', 'public, max-age=' + cacheDuration); + } if (+(new Date(ask.req.headers['if-modified-since'])) >= +serverStartTime) { ask.res.statusCode = 304; ask.res.end(); // not modified.