diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 86c607f3..fb7b8422 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -159,13 +159,10 @@ module.exports = function(){ callback(null, me.channelCache[cacheKey]); return; } - - if ( req.params.token ) { - if ( ! me.channelCache.hasOwnProperty(cacheKey) ) { - callback(new Error('missing channel cache for token ' + req.params.token)); - } else { - callback(null, me.channelCache[cacheKey]); - } + else if ( req.params.token ) { + // cached cache channel for token-based access should be constructed + // at cache creation time + callback(new Error('missing channel cache for token ' + req.params.token)); return; } @@ -219,12 +216,15 @@ module.exports = function(){ } // Set Last-Modified header - // - // Currently sets it to NOW - // - // TODO: find out a real value, querying for most recent change in - // any of the source tables - res.header('Last-Modified', new Date().toUTCString()); + var lastUpdated; + if ( req.params.cache_buster ) { + // Assuming cache_buster is a timestamp + // FIXME: store lastModified in the cache channel instead + lastUpdated = new Date(parseInt(req.params.cache_buster)); + } else { + lastUpdated = new Date(); + } + res.header('Last-Modified', lastUpdated.toUTCString()); me.generateCacheChannel(req, function(err, channel){ if ( ! err ) {