Cache control: w/ cache hit too + re-add 1day for static images
This commit is contained in:
parent
ae09490aed
commit
5602ed50f3
12
server.js
12
server.js
|
@ -14,6 +14,9 @@ var cacheFromIndex = Object.create(null);
|
|||
|
||||
function cache(f) {
|
||||
return function getRequest(data, match, end, ask) {
|
||||
// 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');
|
||||
|
||||
var cacheIndex = match[0] + '?label=' + data.label;
|
||||
// Should we return the data right away?
|
||||
var cached = cacheFromIndex[cacheIndex];
|
||||
|
@ -517,6 +520,9 @@ function(data, match, end, ask) {
|
|||
var color = escapeFormat(match[6]);
|
||||
var format = match[8];
|
||||
|
||||
// Cache management - no cache, so it won't be cached by Github's CDN.
|
||||
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.
|
||||
|
@ -546,6 +552,9 @@ function(data, match, end, ask) {
|
|||
var status = match[2];
|
||||
var color = data.color;
|
||||
|
||||
// Cache management - no cache, so it won't be cached by Github's CDN.
|
||||
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.
|
||||
|
@ -583,9 +592,6 @@ function getLabel(label, data) {
|
|||
}
|
||||
|
||||
function makeSend(format, askres, end) {
|
||||
// Cache management - no cache, so it won't be cached by Github's CDN.
|
||||
askres.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||
|
||||
if (format === 'svg') {
|
||||
return function(res) { sendSVG(res, askres, end); };
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user