Skip to content

Commit 37f1a74

Browse files
authored
fix(@angular/ssr): avoid caching non-SSG page lookups
Only cache CommonEngine SSG lookup results after the target file is confirmed to be a prerendered SSG page.
1 parent 009db66 commit 37f1a74

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

packages/angular/ssr/node/src/common-engine/common-engine.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,19 @@ export class CommonEngine {
167167

168168
if (pagePath === resolve(documentFilePath) || !(await exists(pagePath))) {
169169
// View matches with prerender path or file does not exist.
170-
this.pageIsSSG.set(pagePath, false);
171-
172170
return undefined;
173171
}
174172

175173
// Static file exists.
176174
const content = await fs.promises.readFile(pagePath, 'utf-8');
177175
const isSSG = SSG_MARKER_REGEXP.test(content);
178-
this.pageIsSSG.set(pagePath, isSSG);
176+
if (isSSG) {
177+
this.pageIsSSG.set(pagePath, true);
178+
179+
return content;
180+
}
179181

180-
return isSSG ? content : undefined;
182+
return undefined;
181183
}
182184

183185
private async renderApplication(opts: CommonEngineRenderOptions): Promise<string> {

0 commit comments

Comments
 (0)