CDB-3256 adds headers based on affected tables when creating a layergroup via HTTP GET

This commit is contained in:
Raul Ochoa
2014-06-24 12:16:30 +02:00
parent 86c6f3eeac
commit 5e73b12cf5
+11
View File
@@ -438,6 +438,17 @@ module.exports = function(){
var cacheChannel = me.buildCacheChannel(dbName,tableNames);
// store for caching from me.afterLayergroupCreate
me.channelCache[cacheKey] = cacheChannel;
if (req.res && req.method == 'GET') {
var res = req.res;
if ( req.query && req.query.cache_policy == 'persist' ) {
res.header('Cache-Control', 'public,max-age=31536000'); // 1 year
} else {
var ttl = global.environment.varnish.ttl || 86400;
res.header('Cache-Control', 'public,max-age='+ttl+',must-revalidate');
}
res.header('Last-Modified', (new Date()).toUTCString());
res.header('X-Cache-Channel', cacheChannel);
}
// find last updated
if ( ! tableNames.length ) return 0; // skip for no affected tables
tabNames = tableNames;