角$ HTTP transformResponse和缓存 [英] Angular $http transformResponse and cache

查看:176
本文介绍了角$ HTTP transformResponse和缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从之前或任何transformResponse功能已经应用缓存后的角$ HTTP请求的响应?

Is the response from an Angular $http request cached before or after any transformResponse functions have been applied?

使用情况:
我的客户的REST API返回大量的元数据(其中大部分我不需要),所以我不希望缓存整个响应。我想申请一个特定的transformResponse为每个不同的API端点是只复制领域,我需要到一个新的对象\\阵列和原处分的权利。然后,我想新的对象自动被缓存。如果从transformResponse返回的数据进行缓存这应该是不错的和容易。

Use case: My client's REST API returns a lot of metadata (most of which I don't need) so I don't want to cache the entire response. I'd like to apply a specific transformResponse for each different API end-point that copies only the fields I need into a new object\array and dispose of the original. I would then like the new object to automatically be cached. This should be nice and easy if the return data from transformResponse is cached.

推荐答案

显然正在改变之前缓存,你可以在的 $ HTTP#717 sendReq transformResponse之前被调用,并在的 $ HTTP#958 你可以看到sendReq做缓存

Apparently is cached before transforming, as you can see in $http#717 sendReq is called before transformResponse, and in $http#958 you can see sendReq does the caching

也许你可以做一个测试一定

Maybe you can be sure by doing a test

这篇关于角$ HTTP transformResponse和缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆