You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libs/isr-move/README.md
+70-44Lines changed: 70 additions & 44 deletions
Original file line number
Diff line number
Diff line change
@@ -3,23 +3,26 @@
3
3
</p>
4
4
5
5
# Incremental Static Regeneration for Angular
6
+
6
7
A library that enables Angular Universal applications to generate static pages at runtime and then update them incrementally on demand or on a schedule.
7
8
8
9
📰 [Documentation](https://ngx-isr.vercel.app/)
9
10
10
11
📰 [ISR Blog post](https://itnext.io/incremental-static-regeneration-for-angular-42b0a8440e53)
11
12
12
13
# Features
14
+
13
15
- ⏰ Scheduled cache invalidation
14
16
- ▶️ On-demand cache invalidation
15
-
- 🔌 Plugin based cache handlers
17
+
- 🔌 Plugin based cache handlers
16
18
- 👌 No build changes required!
17
19
- 🅰️ Supports Angular Universal
18
20
- 🛡️ NgModules & Standalone Compatible
19
21
20
22
# How to use it?
21
23
22
24
1. Install npm package
25
+
23
26
```bash
24
27
npm install ngx-isr
25
28
# or
@@ -29,74 +32,88 @@ pnpm add ngx-isr
29
32
```
30
33
31
34
2. Initialize `ISRHandler` inside `server.ts`
35
+
32
36
```ts
33
37
const isr =newISRHandler({
34
38
indexHtml,
35
39
invalidateSecretToken: 'MY_TOKEN', // replace with env secret key ex. process.env.REVALIDATE_SECRET_TOKEN
return`${html}<!-- Hello, I'm modifying the generatedHtml before caching it! -->`
98
-
}
99
-
}),
111
+
async (req, res, next) =>
112
+
awaitisr.render(req, res, next, {
113
+
modifyGeneratedHtml: (req, html) => {
114
+
return`${html}<!-- Hello, I'm modifying the generatedHtml before caching it! -->`;
115
+
},
116
+
})
100
117
);
101
118
```
102
119
@@ -105,6 +122,7 @@ ISRHandler provides `APP_BASE_HREF` by default. And if you want pass `providers`
105
122
5. Add `revalidate` key in route data
106
123
107
124
Example:
125
+
108
126
```ts
109
127
{
110
128
path: "example",
@@ -115,23 +133,20 @@ Example:
115
133
116
134
> **NOTE:** Routes that don't have revalidate key in data won't be handled by ISR. They will fallback to Angular default server side rendering pipeline.
117
135
118
-
119
136
6. Register providers
120
137
To register the ngx-isr providers, you can either import `NgxIsrModule` in your `AppServerModule` or provide `provideISR` in your `AppServerModule` providers.
121
138
122
139
Or, if you are in a standalone app, you can register the providers in your `app.config.server.ts` file.
0 commit comments