Skip to content
Snippets Groups Projects
Commit d5316717 authored by Xiao Gui's avatar Xiao Gui
Browse files

bugfix: fix preview file cache issue

parent 565d1e2e
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment