Invalidate $resource Cache After Post Request

前端 未结 3 1624
眼角桃花
眼角桃花 2020-12-24 14:34

I am using $resource and caching the results of get requests. My problem is that, after post requests, the cache is not being invalidated.

Here is the return value

3条回答
  •  悲哀的现实
    2020-12-24 14:52

    $resource is using the default cache for $http.

    You can access it using: $cacheFactory.get('$http')

    You can remove a key value pair, using the returned caches remove({string} key) method.


    E.g.:

    var key = '...the key you want to remove, e.g. `/nouns/5`...';
    $cacheFactory.get('$http').remove(key);
    

提交回复
热议问题