To add caching inside http is pretty straight forward. ( by passing cache=true )
http://docs.angularjs.org/api/ng.$http has Cache option.
How do I add similar functionality in $resource in angularjs ?
Overview. A factory which creates a resource object that lets you interact with RESTful server-side data sources. The returned resource object has action methods which provide high-level behaviors without the need to interact with the low level $http service. Requires the ngResource module to be installed.
By default, . angular/cache is used as a base directory to store cache results. To change this path to .cache/ng , run the following command: content_copy ng config cli.
Since 1.1.2 (commit), all the $httpConfig options are directly exposed in $resource action objects:
return { Things: $resource('url/to/:thing', {}, { list : { method : 'GET', cache : true } }) };
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With