2. Server-Side Rendering
Activity 9: Implementing the Transfer State Cache
Solution:
- Import
TransferHttpCacheModulefrom@nguniversal/commoninAppModule:import { TransferHttpCacheModule } from '@nguniversal/common'; - Next, import
ServerTransferStateModulefrom@angular/platform-serverinAppServerModule: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: