From d5c552a03a8e91ffb053578b0b9455d9486091e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Tue, 14 Nov 2017 13:53:42 +0100 Subject: [PATCH] Move functionality that sets cache control header to a middleware --- lib/cartodb/controllers/analyses.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/cartodb/controllers/analyses.js b/lib/cartodb/controllers/analyses.js index 52c2976e..5d6ac238 100644 --- a/lib/cartodb/controllers/analyses.js +++ b/lib/cartodb/controllers/analyses.js @@ -19,14 +19,20 @@ AnalysesController.prototype.register = function(app) { userMiddleware, this.prepareContext, this.catalog.bind(this), + this.setCacheControlHeader(), this.sendResponse() ); }; +AnalysesController.prototype.setCacheControlHeader = function () { + return function setCacheControlHeaderMiddleware (req, res, next) { + res.set('Cache-Control', 'public,max-age=10,must-revalidate'); + next(); + }; +}; + AnalysesController.prototype.sendResponse = function() { return function sendResponseMiddleware (req, res) { - res.set('Cache-Control', 'public,max-age=10,must-revalidate'); - res.status(200); if (req.query && req.query.callback) {