Add more specific tests
This commit is contained in:
parent
2e8a5d0d86
commit
a894194b6b
@ -24,7 +24,7 @@ module.exports = function setCacheControlHeader ({
|
||||
|
||||
const directives = [ 'public' ];
|
||||
|
||||
if (affectedTables && !affectedTables.getTables().some(table => !!table.updated_at)) {
|
||||
if (everyAffectedTablesCanBeInvalidated(affectedTables)) {
|
||||
directives.push(`max-age=${fallbackTtl}`);
|
||||
} else {
|
||||
directives.push(`max-age=${ttl}`);
|
||||
@ -40,3 +40,7 @@ module.exports = function setCacheControlHeader ({
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
function everyAffectedTablesCanBeInvalidated (affectedTables) {
|
||||
return affectedTables && affectedTables.getTables().some(table => !table.updated_at);
|
||||
}
|
||||
|
35
test/acceptance/cache/cache-control-header.js
vendored
35
test/acceptance/cache/cache-control-header.js
vendored
@ -72,8 +72,41 @@ describe('cache-control header', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('tile from a dynamic query which doesn\'t use a table' , function (done) {
|
||||
it('tile from joined tables which one of them is NOT included in cdb_tablemetada', function (done) {
|
||||
const ttl = global.environment.varnish.fallbackTtl || FIVE_MINUTES_IN_SECONDS;
|
||||
const mapConfig = createMapConfig([{
|
||||
type: 'cartodb',
|
||||
options: {
|
||||
sql: `
|
||||
select
|
||||
t.cartodb_id,
|
||||
t.the_geom,
|
||||
t.the_geom_webmercator
|
||||
from
|
||||
test_table t,
|
||||
test_table_2 t2
|
||||
where
|
||||
t.cartodb_id = t2.cartodb_id
|
||||
`,
|
||||
cartocss: TestClient.CARTOCSS.POINTS,
|
||||
cartocss_version: '2.3.0'
|
||||
}
|
||||
}]);
|
||||
|
||||
const testClient = new TestClient(mapConfig);
|
||||
|
||||
testClient.getTile(0, 0, 0, {}, function (err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
assert.equal(res.headers['cache-control'], `public,max-age=${ttl}`);
|
||||
testClient.drain(done);
|
||||
});
|
||||
});
|
||||
|
||||
it('tile from a dynamic query which doesn\'t use a table' , function (done) {
|
||||
const ttl = ONE_YEAR_IN_SECONDS;
|
||||
const mapConfig = createMapConfig();
|
||||
|
||||
const testClient = new TestClient(mapConfig);
|
||||
|
Loading…
Reference in New Issue
Block a user