简体   繁体   English

使用BrowserTransferStateModule时TransferHttpCacheModule的目的

[英]Purpose of TransferHttpCacheModule when using BrowserTransferStateModule

I am working on an Angular Universal application and trying to prevent duplicate HTTP calls on server/client in the most efficient way possible. 我正在使用Angular Universal应用程序,并尝试以最有效的方式防止服务器/客户端上的重复HTTP调用。 I have been able to accomplish the task by utilizing ServerTransferStateModule on app.server.module and BrowserTransferStateModule on app.module . 我已经能够通过利用完成任务ServerTransferStateModuleapp.server.moduleBrowserTransferStateModuleapp.module When making my HTTP call, I either get or set a state variable using TransferState . 进行HTTP调用时,我可以使用TransferState获取或设置状态变量。

This works. 这可行。 My question is, what is the purpose of TransferHttpCacheModule because for me it works without using it, but other examples say it's necessary. 我的问题是, TransferHttpCacheModule的目的是什么,因为对我来说,无需使用它就可以工作,但是其他示例说这是必要的。 It does not appear necessary for me so I would like to know how it's supposed to fit in. I appreciate your help! 它对我来说似乎不是必需的,所以我想知道它应该适合什么。感谢您的帮助!

Ok, I did some more testing and it seems like TransferHttpCacheModule does the job automatically when you're utilizing HttpClient. 好的,我进行了更多测试,当您使用HttpClient时,似乎TransferHttpCacheModule自动完成了这项工作。 In my case, I was using Restangular so this didn't work out the box. 就我而言,我使用的是Restangular因此Restangular Thanks. 谢谢。 Hope this helps someone in the future. 希望这对以后的人有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 BrowserTransferStateModule防止缓存 - BrowserTransferStateModule prevent caching Angular 在处理Dependency Injection 时使用工厂函数的目的是什么? - What is the purpose of using factory functions in Angular when dealing with Dependency Injection? 循环依赖性错误TransferHttpCacheModule,LocalizeRouterModule,TranslateModule - Cyclic dependency error TransferHttpCacheModule, LocalizeRouterModule, TranslateModule TransferHttpCacheModule 与 transferstate api 之间的区别 - Difference between TransferHttpCacheModule vs transferstate api 在 Angular 中使用不纯 pipe 的目的 - Purpose of using impure pipe in Angular 在 NgModule 中使用 forRoot 的目的是什么? - What is purpose of using forRoot in NgModule? 使用限定范围的软件包发布到npm的目的是什么? - What is the purpose of publishing to npm using a scoped package? 在angular2中的方法名称之前使用get的目的是什么? - What is the purpose of using get before the method name in angular2? 在 Angular 6 中生成服务时,提供 Injectable 装饰器的目的是什么? - What is the purpose of providedIn with the Injectable decorator when generating Services in Angular 6? 在 Angular 测试 HTTP 请求中使用 testData 的目的是什么 - What is the purpose of using testData in Angular Testing HTTP requests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM