Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85b0dc3

Browse files
committed
chore(isr): rename HTML compression method
1 parent 2ae8857 commit 85b0dc3

File tree

3 files changed

+6
-12
lines changed

3 files changed

+6
-12
lines changed

libs/isr/models/src/isr-handler-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ export interface ISRHandlerConfig {
134134
compressHtml?: CompressHtmlFn;
135135

136136
/**
137-
* Compression solution, it will use gzip by default if not provided.
137+
* Cached Html compression method, it will use gzip by default if not provided.
138138
*/
139-
cacheHtmlCompressionMethod?: 'gzip' | 'brotli' | undefined | null;
139+
htmlCompressionMethod?: string;
140140
}
141141

142142
export interface ServeFromCacheConfig {

libs/isr/server/src/isr-handler.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,7 @@ export class ISRHandler {
236236
This resulted into more ${totalTime}ms of processing time.\n-->`;
237237
}
238238
} else {
239-
setCompressHeader(
240-
res,
241-
this.isrConfig.cacheHtmlCompressionMethod || 'gzip',
242-
);
239+
setCompressHeader(res, this.isrConfig.htmlCompressionMethod);
243240
}
244241

245242
return res.send(finalHtml);
@@ -266,10 +263,7 @@ export class ISRHandler {
266263
throw new Error('Error while generating the page!');
267264
} else {
268265
if (this.isrConfig.compressHtml) {
269-
setCompressHeader(
270-
res,
271-
this.isrConfig.cacheHtmlCompressionMethod || 'gzip',
272-
);
266+
setCompressHeader(res, this.isrConfig.htmlCompressionMethod);
273267
}
274268
return res.send(result.html);
275269
}

libs/isr/server/src/utils/compression-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import * as express from 'express';
33

44
export function setCompressHeader(
55
response: express.Response,
6-
method: string,
6+
method?: string,
77
): void {
8-
response.setHeader('Content-Encoding', method);
8+
response.setHeader('Content-Encoding', method || 'gzip');
99
response.setHeader('Content-type', 'text/html; charset=utf-8');
1010
response.setHeader('Vary', 'Accept-Encoding');
1111
}

0 commit comments

Comments
 (0)