I have added cache in my application with $cacheFactory, but when the user close the browser and then reopen, the cache data about the browsed products is expired.
Are there any way to make it longer? put a date of expiration or something like that?
Thanks.
Edit: I would maybe have to use Breeze.js, but before this I wanted to know if any of you know if it is possible to do it with angularjs (I read the API and there is no info about it :S).
Edit 2: to help, the way in which I use $cacheFactory is like this JSFiddle code.
factory('SomeCache', function($cacheFactory) {
return $cacheFactory('someCache', {
capacity: 3 // optional - turns the cache into LRU cache
});
}).
Edit 3: Lawnchair is not an option, it stores in a javascript array and doesn't persists the data after closing the browser..
$cacheFactory uses in-memory browser storage, which means it doesn't persist across even a page refresh, let alone closing and re-opening the browser.
If you want to cache data across page loads and browser sessions, you're looking for localStorage. See here for a very simple example:
http://jsbin.com/acokis/2/edit
I think you'll want to look at amplify.js or lawnchair.js as they provide nice wrappers for managing localStorage, also also provide fallback adapters for browsers that don't support localStorage (fallback options won't persist across page refreshes though).