I've enabled cache in my $http request and now the callback for success only runs the first time. I'm wondering if this is expected or there's something I need to know about caching $http ?
This is what I've been trying:
$http.get('/foo/bar', { cache: true })
.success(function(data){
// does foo
})
.error(function(){
// uh oh
});
Let's say I've processed the data once, but there's also other commands that I'd like to run, every time. So, if it's true the data is cached or already available I don't want to repeat myself, but let's say, If I'm opening and closing elements with animations, where should this go ?!
Thanks for looking!
I'm pretty sure that the new GET request isn't running so no corresponding success callbacks are called.
You can use the
$cacheFactory
object. See : http://docs.angularjs.org/api/ng.$cacheFactoryYou can cache $http request like that :
If you want to retrieve a specific url in cache do :
$You can clear the cache too :
or :
Complete post here : http://pseudobry.com/power-up-%24http.html