mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 01:18:42 +00:00
Website: Disable caching /dist folder (#5596)
* Website: update custom hook * update comment * Update index.js * lint fixes Co-authored-by: Mike McNeil <mikermcneil@users.noreply.github.com>
This commit is contained in:
parent
adc7425501
commit
922da1592e
1 changed files with 15 additions and 7 deletions
22
website/api/hooks/custom/index.js
vendored
22
website/api/hooks/custom/index.js
vendored
|
|
@ -151,9 +151,23 @@ will be disabled and/or hidden in the UI.
|
|||
return res.redirect(sails.config.custom.baseUrl+req.url);
|
||||
}//•
|
||||
|
||||
// Prevent the browser from caching logged-in users' pages.
|
||||
// (including w/ the Chrome back button)
|
||||
// > • https://mixmax.com/blog/chrome-back-button-cache-no-store
|
||||
// > • https://madhatted.com/2013/6/16/you-do-not-understand-browser-history
|
||||
//
|
||||
// This also prevents an issue where webpages may be cached by browsers, and thus
|
||||
// reference an old bundle file (e.g. dist/production.min.js or dist/production.min.css),
|
||||
// which might have a different hash encoded in its filename. This way, by preventing caching
|
||||
// of the webpage itself, the HTML is always fresh, and thus always trying to load the latest,
|
||||
// correct bundle files.
|
||||
res.setHeader('Cache-Control', 'no-cache, no-store');
|
||||
|
||||
// No session? Proceed as usual.
|
||||
// (e.g. request for a static asset)
|
||||
if (!req.session) { return next(); }
|
||||
if (!req.session) {
|
||||
return next();
|
||||
}
|
||||
|
||||
// Not logged in? Proceed as usual.
|
||||
if (!req.session.userId) { return next(); }
|
||||
|
|
@ -233,12 +247,6 @@ will be disabled and/or hidden in the UI.
|
|||
|
||||
}//fi
|
||||
|
||||
// Prevent the browser from caching logged-in users' pages.
|
||||
// (including w/ the Chrome back button)
|
||||
// > • https://mixmax.com/blog/chrome-back-button-cache-no-store
|
||||
// > • https://madhatted.com/2013/6/16/you-do-not-understand-browser-history
|
||||
res.setHeader('Cache-Control', 'no-cache, no-store');
|
||||
|
||||
return next();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue