Expose Varnish cache TTL in configuration. Closes #46
This commit is contained in:
parent
c23f136f04
commit
87b0e07815
@ -32,7 +32,8 @@ var config = {
|
|||||||
}
|
}
|
||||||
,varnish: {
|
,varnish: {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 6082
|
port: 6082,
|
||||||
|
ttl: 86400
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@ var config = {
|
|||||||
}
|
}
|
||||||
,varnish: {
|
,varnish: {
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
port: 6082
|
port: 6082,
|
||||||
|
ttl: 86400
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -27,7 +27,8 @@ var config = {
|
|||||||
}
|
}
|
||||||
,varnish: {
|
,varnish: {
|
||||||
host: '',
|
host: '',
|
||||||
port: null
|
port: null,
|
||||||
|
ttl: 86400
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8,10 +8,11 @@ var CartodbWindshaft = function(serverOptions) {
|
|||||||
|
|
||||||
// set the cache chanel info to invalidate the cache on the frontend server
|
// set the cache chanel info to invalidate the cache on the frontend server
|
||||||
serverOptions.afterTileRender = function(req, res, tile, headers, callback) {
|
serverOptions.afterTileRender = function(req, res, tile, headers, callback) {
|
||||||
|
var ttl = global.environment.varnish.ttl || 86400;
|
||||||
Cache.generateCacheChannel(req, function(channel){
|
Cache.generateCacheChannel(req, function(channel){
|
||||||
res.header('X-Cache-Channel', channel);
|
res.header('X-Cache-Channel', channel);
|
||||||
res.header('Last-Modified', new Date().toUTCString());
|
res.header('Last-Modified', new Date().toUTCString());
|
||||||
res.header('Cache-Control', 'no-cache,max-age=86400,must-revalidate, public');
|
res.header('Cache-Control', 'no-cache,max-age='+ttl+',must-revalidate, public');
|
||||||
callback(null, tile, headers);
|
callback(null, tile, headers);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user