0

Is it possible to use a file (.js / .json) the angular.js cache for $http.get?

We have an angular application, and we want to download some pages and view them offline. So, the idea is, before downloading, we make all the necessary $http.get calls, and save the responses in some json / js file. When we open the pages offline, we want the $http.get calls to access this file and use it as a cache.

It sounds like it should be possible, but I'm new to angular, so I'm not sure how to configure that.

4

2 Answers 2

1

You can utilise following techniques:

  1. Browser's localStorage, angular-local-storage
  2. Service worker to intelligently recache requests, configurable plugin sw-precache for you build tool

Besides that:

  • you can enable caching of $http.get requests:

    $http({ cache: true, url: url, method: 'GET'}).success(...);

  • you can make use of angular $templateCache : https://docs.angularjs.org/api/ng/service/$templateCache

Sign up to request clarification or add additional context in comments.

Comments

0

Hey this might help you jsCache

You can store api data in storage of your choice for desired time period you want. Just have an look @ https://github.com/funwithjs/jsCache

1 Comment

you should have added a note that you're the author of this lib

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.