AngularJS provides a simple caching system for your HTTP GET requests out of the box. To improve the performance of our application, we can turn on the framework's caching mechanism. It will store each response from the server, returning the same result every time the same request is made.

It comes disabled for all requests by default, but to enable caching for your requests, all you need to do is:
$http.get('http://server/myapi', {
cache: true
}).success(function() { // Handle success });

In the following code, we are enabling the cache mechanism.

run.js ($http) {
$http.defaults.cache = true;
Related Tutorial
Follow Us #