0

I am making a mobile SPA application, using AngularJS and Breeze.

The users of this application are going to be able to watch some items and I want the application to remember what items the user has watched and how often. From this information I want to be able to create a list of "favorite items" or "Recent items".

I am NOT thinking of saving this information to the back-end. I want this information saved in browser cache - until the browser cache is cleared at some time.

How would I do this?

Cookies?

Does Angular or Breeze have something to help me achieve this?

2 Answers2

2

In general, you can use in memory cache or a local storage. There are really very good angular plugins, making the use of these very simple:

The Angular cache has API with methods like:

.get(key)
.put(key, value)
.clearAll()

read more here http://jmdobry.github.io/angular-cache/api.html

The Local storage has similar

.get(key)
.add(key, value)
.clearAll()

read more here http://gregpike.net/demos/angular-local-storage/demo/demo.html

Also this blog post Power up Angular's $http service with caching provides nice overview.

The most interesting is, that these two concepts can even work together, ie. some cached stuff (in memory) could also be placed into local storage ... available later, please check:

Summary: the Angular-cache and the Local-storage plugins provide the very nice and simple API for interection with the cache on the client

Community
  • 1
  • 1
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
2

If you are going to use BreezeJs, you should take advantage of Breeze capabilities for caching.

With Breeze you can indicate your query to be done only from data in cache.

In the next link, there are more information. I recommend you to take a look to the documentation of breeze. http://www.breezejs.com/documentation/entitymanager-and-caching

jvrdelafuente
  • 1,992
  • 14
  • 23