Query AngularJS $ cacheFactory values

I have correctly installed Restangular to cache my HTTP requests via:

Restangular.withConfig(function(RestangularConfigurer) {
    RestangularConfigurer.setDefaultHttpFields({cache: true});
});

      

I would like, however, to be able to manually cache items at a specific point in time, such as when they become obsolete due to user modification of those objects. Is there a way to do this? I tried:

$cacheFactory.get('$http').info()
Object {id: "$http", size: 7}

      

+3


source to share


1 answer


Just use the $ cacheFactory API as described here:

For example, to invalidate a given cache entry:

$cacheFactory.get('$http').remove(myGetUrlToInvalidate);

      

myGetUrlToInvalidate is a string representation of your GET request url. You may need to test to figure out if a URL is relative or absolute, check out the following version of the stackoverflow discussion:



Also interesting is this stackoverflow discussion pointing to an alternative cache implementation:

Reserve resources:

+2


source







All Articles