diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 25468e8e..a98e09ae 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -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;