AngularJS $http cache expiration time

后端 未结 4 932
你的背包
你的背包 2021-02-13 12:50

Can you set an expiration time for Angular\'s $http default caching system ? I would like that an URL stays in the cache for 1 minute, so that any requests made to it after 1 mi

4条回答
  •  爱一瞬间的悲伤
    2021-02-13 13:39

    There is no way to set the expiration time. But you can do it manually. You have to access the $http cache:

    var cache = $cacheFactory.get('$http');
    

    and remove the url that is cached by:

    cache.remove(theUrl);
    

    See documentation for more information.

提交回复
热议问题