2. Server-Side Rendering
Activity 9: Implementing the Transfer State Cache
Solution:
- Import
TransferHttpCacheModule
from@nguniversal/common
inAppModule
:import { TransferHttpCacheModule } from '@nguniversal/common';
- Next, import
ServerTransferStateModule
from@angular/platform-server
inAppServerModule
:import { ServerTransferStateModule } from '@angular/platform-server';
Now when you create a new build of the app, you will only see that the API request gets made once.
If you view the source of the server-side rendered page, you should see the application state as a snippet of JSON at the bottom of the page: