Reputation: 49815
hi as i read from the Angular documentation this is how to set the cache on $http request:
cache – {boolean|Cache} – If true, a default $http cache will be used to cache the GET request, otherwise if a cache instance built with $cacheFactory, this cache will be used for caching.
I mean setting {cache:true}
how much time the request will be cached for??
Is possible to set the cache max time?
Upvotes: 6
Views: 4124
Reputation: 16341
This cache keeps the loaded data as long as the full html site did not change. E.g. if you have a regular SPA the data are kept in cache for the full app lifetime. There is no build in way to set a maximum cache time. If you would like to clear the cache you have to do it by your self.
var cache = $cacheFactory.get('$http');
cache.removeAll();
More information regarding the $cacheFactory: http://docs.angularjs.org/api/ng.$cacheFactory
Upvotes: 11