0

I store some keys in cache using angularJs cachefactory

myApp.factory('SomeCache', function ($cacheFactory) {
    return $cacheFactory('someCache', {
        capacity: 10 // optional - turns the cache into LRU cache
    });
});

in the code :

SomeCache.put(key, value);

I see all the keys and values in the console. The problem is , when i redirect to another page, not in my webSite ( e.c www.ebay.com) and the i come back the cache object is empty, I needd to preserve the data on the page.

Any idea ? ishay

1 Answer 1

2

The behaviour you see with $cacheFactory is expected. The AngularJS-Cache does not persist between page refreshes. See also: Angularjs: date expiration for $cacheFactory

What you need to use to persist data between page refreshes is localStorage or sessionStorage as explained on this site: DOM Storage guide

You should use the excellent ngStorage module.

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

1 Comment

heh, I was halfway through typing this exact answer.

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.