Search code examples
angularjsangular-resource

using http cache in angularjs-rails-resource


I'm using the angularjs-rails-resource project to wrap my http rest services. One thing I didn't find in documentation is regarding cache, some of my methods should access the server only once and cache their response.

Is there an easy way to achieve this?


Solution

  • You can pass options to $http through your resource configuration (i.e. httpConfig) like so:

    return railsResourceFactory({
      url: '/books',
      name: 'book',
      httpConfig: {
        cache: true
      }
    });