search

Home  >  Q&A  >  body text

angular.js - angular caching problem

$http.get('http://server/myapi', {

cache: true  

}).success(function() {//Processing success});

$http.get added a cache. I requested records. The first time I requested the data on the URL, I refreshed it many times and never requested data again. . What is the update mechanism for cache here? Under what circumstances can the data on the website be obtained again?

天蓬老师天蓬老师2830 days ago550

reply all(2)I'll reply

  • 黄舟

    黄舟2017-05-15 16:58:50

    Generally, I recommend AngularCache
    https://github.com/jmdobry/angular-cache

    Can be set to expire by time

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-15 16:58:50

    Save cache

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

    Then you can control
    $httpDefaultCache.remove(key);
    // key is your url such as /api/user/current/51a9020d91799f1e9b8db12f

    reply
    0
  • Cancelreply