Answer the question
In order to leave comments, you need to log in
How to properly cache in Angular?
Is it correct to cache the request like this or is there a smarter practice?
// фактори в которой определяем кеширование
function datacache($cacheFactory) {
return $cacheFactory('megaCache', {});
}
// запрос
function money(){
var name = 'money';
var data = datacache.get(name);
if(data){
return data;
}
return req.option('money').then(function (res){
datacache.put(name,res);
return res;
});
}
Answer the question
In order to leave comments, you need to log in
https://docs.angularjs.org/api/ng/service/$http#caching
in general, it seems to be normal, the only thing that I would immediately put a promise in the cache is that all the other dudes would also wait and not pull again apishka.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question