Skip to content

Commit

Permalink
disable browser caching for static resources in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Apr 17, 2024
1 parent d174fad commit 5a49783
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ export class Server extends AbstractServer {
}

const maxAge = Time.days.toMilliseconds;
const cacheOptions = inE2ETests ? {} : { maxAge };
const { staticCacheDir } = Container.get(InstanceSettings);
if (frontendService) {
const serveIcons: express.RequestHandler = async (req, res) => {
Expand All @@ -365,7 +366,7 @@ export class Server extends AbstractServer {
if (filePath) {
try {
await fsAccess(filePath);
return res.sendFile(filePath, { maxAge, immutable: true });
return res.sendFile(filePath, cacheOptions);
} catch {}
}
res.sendStatus(404);
Expand Down Expand Up @@ -398,6 +399,7 @@ export class Server extends AbstractServer {
// Route all UI urls to index.html to support history-api
const nonUIRoutes: Readonly<string[]> = [
'assets',
'types',
'healthz',
'metrics',
'e2e',
Expand Down Expand Up @@ -429,12 +431,12 @@ export class Server extends AbstractServer {

this.app.use(
'/',
express.static(staticCacheDir, { maxAge }),
express.static(EDITOR_UI_DIST_DIR, { maxAge, immutable: true }),
express.static(staticCacheDir, cacheOptions),
express.static(EDITOR_UI_DIST_DIR, cacheOptions),
historyApiHandler,
);
} else {
this.app.use('/', express.static(staticCacheDir, { maxAge }));
this.app.use('/', express.static(staticCacheDir, cacheOptions));
}
}

Expand Down

0 comments on commit 5a49783

Please sign in to comment.