Local storage vs AngularJS $cacheFactory

后端 未结 4 624
刺人心
刺人心 2020-12-12 12:27

I have a problem of storing a lot of client-side data, and I can\'t decide which way is better. Now I\'m using AngularJS\'s cacheFactory, it works fine, but all data reloads

4条回答
  •  一生所求
    2020-12-12 13:04

    An alternative solution is http://jmdobry.github.io/angular-cache/ which works well with ngResource and can also easily be configured to sync to localStorage, so requests don't need to be re-done after page refresh.

    $resource('my/kewl/url/:key', { key: '@key' }, {
      'get': { method: 'GET', 
               cache: $angularCacheFactory('MyKewlResourceCache', { 
                                              storageMode: 'localStorage' })
             }
    });
    

提交回复
热议问题