Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular js - $http cache time?

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?

like image 244
itsme Avatar asked Feb 09 '14 14:02

itsme


1 Answers

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

like image 71
michael Avatar answered Oct 22 '22 23:10

michael