Skip to content

Commit e33a18a

Browse files
committed
docs: update documentation
1 parent c32ece3 commit e33a18a

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ Install & save the library to your package.json:
2525
$ npm i -S @trilon/ng-universal
2626
```
2727

28+
## Modules Available
29+
30+
- [NgUniversalModule](#nguniversalmodule-setup)
31+
- [NgUniversalModule](#TransferHttpCacheModule-setup)
32+
2833
---
2934

30-
### AppModule Setup
35+
## NgUniversalModule Setup
3136

3237
Now add ApplicationInsightsModule to your Angular Root `AppModule`:
3338

@@ -86,12 +91,40 @@ Take as an example a Twitter Feed section that's connected to 3rd party Componen
8691

8792
More Documentation Coming soon...
8893

94+
---
95+
96+
# TransferHttpCacheModule Setup
97+
98+
In order to prevent UI flickers with Angular Universal we want to make sure we're caching Http responses and re-using them during the client-side render. This Module helps not only Cache `GET` requests, but `POST` requests as well.
99+
100+
```ts
101+
// Import the Application Insights module and the service provider
102+
import { TransferHttpCacheModule } from '@trilon/ng-universal';
103+
104+
export function cachePostFilter (req, key) {
105+
// This will Cache -ALL- "POST" Responses, you can also make sure only specific requests get cached (or none)
106+
// By utilizing req.url and allowing specific ones to return true
107+
return true;
108+
}
109+
110+
@NgModule({
111+
imports: [
112+
// ...
113+
// Add the Module to your imports
114+
TransferHttpCacheModule.forRoot({
115+
cachePOSTFilter: cachePostFilter
116+
})
117+
]
118+
})
119+
export class AppModule { }
120+
```
121+
89122

90123
# License
91124

92125
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge&color=e51384)](/LICENSE)
93126

94-
Copyright (c) 2016-2019 [Trilon](https://trilon.io)
127+
Copyright (c) 2019 [Trilon](https://trilon.io)
95128

96129
[![Twitter Follow](https://img.shields.io/twitter/follow/Trilon_io.svg?style=social)](https://twitter.com/Trilon_io)
97130

libraries/ng-universal/README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ Install & save the library to your package.json:
2525
$ npm i -S @trilon/ng-universal
2626
```
2727

28+
## Modules Available
29+
30+
- [NgUniversalModule](#nguniversalmodule-setup)
31+
- [NgUniversalModule](#TransferHttpCacheModule-setup)
32+
2833
---
2934

30-
### AppModule Setup
35+
## NgUniversalModule Setup
3136

3237
Now add ApplicationInsightsModule to your Angular Root `AppModule`:
3338

@@ -86,12 +91,40 @@ Take as an example a Twitter Feed section that's connected to 3rd party Componen
8691

8792
More Documentation Coming soon...
8893

94+
---
95+
96+
# TransferHttpCacheModule Setup
97+
98+
In order to prevent UI flickers with Angular Universal we want to make sure we're caching Http responses and re-using them during the client-side render. This Module helps not only Cache `GET` requests, but `POST` requests as well.
99+
100+
```ts
101+
// Import the Application Insights module and the service provider
102+
import { TransferHttpCacheModule } from '@trilon/ng-universal';
103+
104+
export function cachePostFilter (req, key) {
105+
// This will Cache -ALL- "POST" Responses, you can also make sure only specific requests get cached (or none)
106+
// By utilizing req.url and allowing specific ones to return true
107+
return true;
108+
}
109+
110+
@NgModule({
111+
imports: [
112+
// ...
113+
// Add the Module to your imports
114+
TransferHttpCacheModule.forRoot({
115+
cachePOSTFilter: cachePostFilter
116+
})
117+
]
118+
})
119+
export class AppModule { }
120+
```
121+
89122

90123
# License
91124

92125
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge&color=e51384)](/LICENSE)
93126

94-
Copyright (c) 2016-2019 [Trilon](https://trilon.io)
127+
Copyright (c) 2019 [Trilon](https://trilon.io)
95128

96129
[![Twitter Follow](https://img.shields.io/twitter/follow/Trilon_io.svg?style=social)](https://twitter.com/Trilon_io)
97130

0 commit comments

Comments
 (0)