Skip to content

Commit

Permalink
Merge pull request #21574 from storybookjs/norbert/fix-21443-no-cachi…
Browse files Browse the repository at this point in the history
…ng-in-decmode

Bug: disable cache in dev-mode
  • Loading branch information
ndelangen authored Mar 15, 2023
2 parents b5c3281 + b784421 commit f229785
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions code/lib/core-server/src/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { getStoryIndexGenerator } from './utils/getStoryIndexGenerator';
import { doTelemetry } from './utils/doTelemetry';
import { router } from './utils/router';
import { getAccessControlMiddleware } from './utils/getAccessControlMiddleware';
import { getCachingMiddleware } from './utils/get-caching-middleware';

export async function storybookDevServer(options: Options) {
const app = express();
Expand Down Expand Up @@ -48,6 +49,7 @@ export async function storybookDevServer(options: Options) {
}

app.use(getAccessControlMiddleware(core?.crossOriginIsolated));
app.use(getCachingMiddleware());

getMiddleware(options.configDir)(router);

Expand Down
8 changes: 8 additions & 0 deletions code/lib/core-server/src/utils/get-caching-middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { RequestHandler } from 'express';

export function getCachingMiddleware(): RequestHandler {
return (req, res, next) => {
res.header('Cache-Control', 'no-store');
next();
};
}

0 comments on commit f229785

Please sign in to comment.