2

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?

1 Answer 1

2

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

return railsResourceFactory({
  url: '/books',
  name: 'book',
  httpConfig: {
    cache: true
  }
});
Sign up to request clarification or add additional context in comments.

2 Comments

And how can I invalidate the cache ?
You'll need to provide your own cache mechanism (see here). Here's one popular replacement for Angular's $cacheFactory that works with $http: github.com/jmdobry/angular-cache#using-angular-cache-with-http

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.