[英]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
. 我已经能够通过利用完成任务
ServerTransferStateModule
上app.server.module
和BrowserTransferStateModule
上app.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.