From 65c7c5fc9c64e7e7a8b6447ed0f3180ff29d8d47 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 8 Jul 2013 12:13:45 +0200 Subject: [PATCH] Always serve multilayer tiles and grids with persisting cache request --- lib/cartodb/server_options.js | 1 + test/acceptance/multilayer.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 62b32aa6..177d6aab 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -210,6 +210,7 @@ module.exports = function(){ if ( req.method != 'GET' || ! req.res ) { cb(null, null); return; } var res = req.res; var cache_policy = req.query.cache_policy; + if ( req.params.token ) cache_policy = 'persist'; if ( cache_policy == 'persist' ) { res.header('Cache-Control', 'public,max-age=31536000'); // 1 year } else { diff --git a/test/acceptance/multilayer.js b/test/acceptance/multilayer.js index c6daa746..d9e15e6d 100644 --- a/test/acceptance/multilayer.js +++ b/test/acceptance/multilayer.js @@ -92,8 +92,12 @@ suite('multilayer', function() { assert.equal(res.statusCode, 200, res.body); assert.equal(res.headers['content-type'], "image/png"); + // Check Cache-Control + var cc = res.headers['cache-control']; + assert.equal(cc, 'public,max-age=31536000'); // 1 year + // Check X-Cache-Channel - var cc = res.headers['x-cache-channel']; + cc = res.headers['x-cache-channel']; assert.ok(cc); var dbname = 'cartodb_test_user_1_db' assert.equal(cc.substring(0, dbname.length), dbname);