From d5316717e204dd0f2e2dda66d1cc0e8059a77f86 Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Wed, 7 Aug 2019 12:21:02 +0200 Subject: [PATCH] bugfix: fix preview file cache issue --- deploy/datasets/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/deploy/datasets/index.js b/deploy/datasets/index.js index e97436626..edb58cdf6 100644 --- a/deploy/datasets/index.js +++ b/deploy/datasets/index.js @@ -25,6 +25,15 @@ const noCacheMiddleWare = (_req, res, next) => { next() } +const getVary = (headers) => (_req, res, next) => { + if (!headers instanceof Array) { + console.warn(`getVary arguments needs to be an Array of string`) + return next() + } + res.setHeader('Vary', headers.join(', ')) + next() +} + datasetsRouter.use('/spatialSearch', noCacheMiddleWare, require('./spatialRouter')) datasetsRouter.get('/templateName/:templateName', noCacheMiddleWare, (req, res, next) => { @@ -59,7 +68,10 @@ datasetsRouter.get('/parcellationName/:parcellationName', noCacheMiddleWare, (re }) }) -datasetsRouter.get('/preview/:datasetName', cacheMaxAge24Hr, (req, res, next) => { +/** + * It appears that query param are not + */ +datasetsRouter.get('/preview/:datasetName', getVary(['referer']), cacheMaxAge24Hr, (req, res, next) => { const { datasetName } = req.params const ref = url.parse(req.headers.referer) const { templateSelected, parcellationSelected } = qs.parse(ref.query) -- GitLab