From cb69faffc0d9ea1aed24e3fbae95eeae76658751 Mon Sep 17 00:00:00 2001 From: javi Date: Tue, 29 Nov 2011 21:19:10 +0100 Subject: [PATCH] added X-Cache-Channel header so the tile cache could be invalidated using that key for the moment we're using the database name as cache key, it is not the best solution because all the tiles for that database will be invalidated when a change is done in any table. Doing this we avoid getting wrong data when user gets tiles which come from a query with joins. --- lib/cartodb/cartodb_windshaft.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index 195f00b6..568fc002 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -16,12 +16,18 @@ var CartodbWindshaft = function(serverOptions) { afterTileRender: lru_cache.afterTileRender, cacheStats: lru_cache.getStats, afterStateChange: lru_cache.afterStateChange - }) + }); } + // set the cache chanel info to invalidate the cache on the frontend server + serverOptions.afterTileRender = function(req, res, tile, headers, callback) { + res.header('X-Cache-Channel', req.params.dbname); + callback(null, tile, headers); + }; // boot var ws = new Windshaft.Server(serverOptions); + /** * Helper to allow access to the layer to be used in the maps infowindow popup. */