Take cache_buster value, if present, as a Last-Modified timestamp

This makes the Last-Modified header consistent across requests
using the same cache_buster (embedded in the token for multilayer
API).
This commit is contained in:
Sandro Santilli 2013-07-15 13:48:06 +02:00
parent 76c056c7a1
commit 381b9a9edf

View File

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