3

I've correctly set Restangular to cache my http requests via:

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

I would like, however, to be able to manually certain cached elements at a given point in time, eg when they become obsolete due to the user modifying these objects. Is there a way to do this? I've tried:

$cacheFactory.get('$http').info()
Object {id: "$http", size: 7}
rebelliard
  • 9,592
  • 6
  • 47
  • 80

1 Answers1

2

Just make use of the $cacheFactory API as documented here:

For instance, to invalidate a given cache entry:

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

myGetUrlToInvalidate is a string representation of your GET request URL. You may have to test to find out whether its the relative or absolute URL, check out following stackoverflow discussion for more details:

Also of interest this stackoverflow discussion pointing to an alternate cache implementation:

Restangular resources:

Community
  • 1
  • 1