mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Disable HTTP caching for dynamic responses
This commit is contained in:
parent
f69570db7d
commit
0a2f3a4faa
1 changed files with 9 additions and 0 deletions
|
|
@ -88,6 +88,10 @@ app.use(compression());
|
|||
app.use('/static', express.static(path.join(buildPath, 'static')));
|
||||
app.use(cookieParser());
|
||||
|
||||
const noCacheHeaders = {
|
||||
'Cache-control': 'no-cache, no-store, must-revalidate',
|
||||
};
|
||||
|
||||
app.get('*', (req, res) => {
|
||||
if (req.url.startsWith('/static/')) {
|
||||
// The express.static middleware only handles static resources
|
||||
|
|
@ -121,6 +125,11 @@ app.get('*', (req, res) => {
|
|||
],
|
||||
});
|
||||
|
||||
// Until we have a better plan for caching dynamic content and we
|
||||
// make sure that no sensitive data can appear in the prefetched
|
||||
// data, let's disable response caching altogether.
|
||||
res.set(noCacheHeaders);
|
||||
|
||||
dataLoader
|
||||
.loadData(req.url, sdk)
|
||||
.then(preloadedState => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue