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

Skip to content

Commit 8e753fb

Browse files
committed
docs(isr): add doc for allowed query params option
1 parent 2a15c5a commit 8e753fb

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

apps/docs/docs/isr/getting-started.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ export function app(): express.Express {
101101

102102
const commonEngine = new CommonEngine();
103103

104+
// This array of query params will be allowed to be part of the cache key. If null, all query params will be allowed. If empty, no query params will be allowed.
105+
const allowedQueryParams = ['page'];
106+
104107
// 2. 👇 Instantiate the ISRHandler class with the index.html file
105108
// highlight-start
106109
const isr = new ISRHandler({
@@ -111,14 +114,12 @@ export function app(): express.Express {
111114
browserDistFolder,
112115
bootstrap,
113116
commonEngine,
117+
allowedQueryParams,
114118
});
115119
// highlight-end
116120

117121
server.use(express.json());
118-
server.post(
119-
'/api/invalidate',
120-
async (req, res) => await isr.invalidate(req, res)
121-
);
122+
server.post('/api/invalidate', async (req, res) => await isr.invalidate(req, res));
122123

123124
server.set('view engine', 'html');
124125
server.set('views', browserDistFolder);
@@ -130,7 +131,7 @@ export function app(): express.Express {
130131
'*.*',
131132
express.static(browserDistFolder, {
132133
maxAge: '1y',
133-
})
134+
}),
134135
);
135136

136137
// 3. 👇 Use the ISRHandler to handle the requests
@@ -140,7 +141,7 @@ export function app(): express.Express {
140141
// Serve page if it exists in cache
141142
async (req, res, next) => await isr.serveFromCache(req, res, next),
142143
// Server side render the page and add to cache if needed
143-
async (req, res, next) => await isr.render(req, res, next)
144+
async (req, res, next) => await isr.render(req, res, next),
144145
);
145146
// highlight-end
146147

@@ -177,9 +178,7 @@ import { ISRHandler } from '@rx-angular/isr/server';
177178
export function app(): express.Express {
178179
const server = express();
179180
const distFolder = join(process.cwd(), 'dist/docs/browser');
180-
const indexHtml = existsSync(join(distFolder, 'index.original.html'))
181-
? 'index.original.html'
182-
: 'index';
181+
const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';
183182

184183
// 2. 👇 Instantiate the ISRHandler class with the index.html file
185184
// highlight-start
@@ -204,7 +203,7 @@ export function app(): express.Express {
204203
// Serve page if it exists in cache
205204
async (req, res, next) => await isr.serveFromCache(req, res, next),
206205
// Server side render the page and add to cache if needed
207-
async (req, res, next) => await isr.render(req, res, next)
206+
async (req, res, next) => await isr.render(req, res, next),
208207
);
209208
// highlight-end
210209

0 commit comments

Comments
 (0)