diff --git a/lib/cartodb/api/middlewares/cache-control-header.js b/lib/cartodb/api/middlewares/cache-control-header.js index 1ef3f2df..c3bb9673 100644 --- a/lib/cartodb/api/middlewares/cache-control-header.js +++ b/lib/cartodb/api/middlewares/cache-control-header.js @@ -25,9 +25,9 @@ module.exports = function setCacheControlHeader ({ const directives = [ 'public' ]; if (everyAffectedTablesCanBeInvalidated(affectedTables)) { - directives.push(`max-age=${fallbackTtl}`); - } else { directives.push(`max-age=${ttl}`); + } else { + directives.push(`max-age=${fallbackTtl}`); } if (revalidate) { @@ -42,5 +42,5 @@ module.exports = function setCacheControlHeader ({ }; function everyAffectedTablesCanBeInvalidated (affectedTables) { - return affectedTables && affectedTables.getTables().some(table => !table.updated_at); + return affectedTables && affectedTables.getTables().every(table => !!table.updated_at); }