Generalize maxAge
This commit is contained in:
parent
d41c73db42
commit
38f9625cde
|
@ -171,7 +171,7 @@ vendorDomain.on('error', function(err) {
|
||||||
function cache(f) {
|
function cache(f) {
|
||||||
return function getRequest(data, match, end, ask) {
|
return function getRequest(data, match, end, ask) {
|
||||||
if (data.maxAge !== undefined && /^[0-9]+$/.test(data.maxAge)) {
|
if (data.maxAge !== undefined && /^[0-9]+$/.test(data.maxAge)) {
|
||||||
var maxAge = +data.maxAge;
|
ask.res.setHeader('Cache-Control', 'max-age=' + data.maxAge);
|
||||||
} else {
|
} else {
|
||||||
// Cache management - no cache, so it won't be cached by GitHub's CDN.
|
// Cache management - no cache, so it won't be cached by GitHub's CDN.
|
||||||
ask.res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
|
ask.res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||||
|
@ -214,6 +214,7 @@ function cache(f) {
|
||||||
badge(cached.badgeData, makeSend(cached.format, ask.res, end));
|
badge(cached.badgeData, makeSend(cached.format, ask.res, end));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ask.res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||||
var badgeData = getBadgeData('vendor', data);
|
var badgeData = getBadgeData('vendor', data);
|
||||||
badgeData.text[1] = 'unresponsive';
|
badgeData.text[1] = 'unresponsive';
|
||||||
var extension;
|
var extension;
|
||||||
|
@ -273,10 +274,6 @@ function cache(f) {
|
||||||
};
|
};
|
||||||
requestCache.set(cacheIndex, updatedCache);
|
requestCache.set(cacheIndex, updatedCache);
|
||||||
if (!cachedVersionSent) {
|
if (!cachedVersionSent) {
|
||||||
// Set the cache interval if specified.
|
|
||||||
if (maxAge !== undefined) {
|
|
||||||
ask.res.setHeader('Cache-Control', 'max-age=' + maxAge);
|
|
||||||
}
|
|
||||||
badge(badgeData, makeSend(format, ask.res, end));
|
badge(badgeData, makeSend(format, ask.res, end));
|
||||||
}
|
}
|
||||||
}, cachedRequest);
|
}, cachedRequest);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user