iConnor
iConnor

Reputation: 20189

What is $cacheFactory?

I can find absolutely no information on what exactly $cacheFactory is and how it can be useful in your application.

The Angular Documentation says

"Factory that constructs cache objects and gives access to them." -- $cacheFactory

Well, that wasn't at all helpful, what does that mean? There doesn't seem to be anything on Google either.

Can someone please explain What it is & When can it be useful.

Thanks in advance.

Upvotes: 3

Views: 1324

Answers (1)

Thomas Pons
Thomas Pons

Reputation: 7729

Oh the $cacheFactory is simple as i understand it :

If you have a request to retrieve constant data for example like a list of cities.

It's not a good pattern to get this list from the server each time the user go on a form where he has to select a city !

So you have to cache this list. The cacheFactory is done for that !

If you're using $http instead of $resource you can enbale the cache just like that :

$http.get('myUrl', { cache: true })

Upvotes: 6

Related Questions