Can-connect and localStorage

This is a follow up post to questions #3 & #5 of my previous post,
http://forums.bitovi.com/t/non-component-modules-non-npm-libraries-and-other-questions/117

I have 2 types of models that I want to use.

The first one is a call to the server for a json document with all of the content and styling data I need to render on a samsung monitor. The response from the server will either be the document or an error message (such as the monitor is not registered).

  1. How does can-connect deal with error messages from the server in place of real data?

The document is then saved to localStorage and at this point I should be able to disconnect from the Internet and will run everything I need. Next time the monitor is turned on, it should pull the data from localStorage. Now it looks like cacheRequests with the data-localStorage-cache is perfect for this. However, after the page is displayed from the data in localStorage, I want to override the cache and force a call to the server to check for updates.

  1. How do I override cacheRequests and call the server?

The 2nd model is, after receiving the document from the 1st model, I want to parse it and organize the data into objects that will be used for the template rendering (basically can.Map/List for the viewModel) and then save those objects to localStorage, so I can quickly retrieve the data without having to parse the original document again.

  1. Is using can-connect/superMap to retrieve/save data to localStorage and NEVER call the sever the right approach? Basically I want to treat localStorage (or IndexedDB) as my data store and not just for caching with these objects.

  2. If can-connect is the right approach, is there a way to do this with the existing can-connect tools, or will I need to create my own behavior to do this?

  3. Ideally I would to abstract this further so that the application has no knowledge of the underlying data store, so for example I could switch out localStorage for IndexedDB (for example) without affecting any application code. Any thoughts on this?