Client-side application cache

A client needs an application cache to ensure that there is self-consistency throughout the application (and avoid stale data). Doing this requires that the client is able to insert resources into the application state. It is usually the case that a client requires a URI inside the network and must insert it in the correct location for self-consistency. Without this approach each controller has its own copy of a resource. This tutorial demonstrates how use an existing application cache utility (rather than how to build one yourself).

application cache

General guidelines

  • a representation is always placed in relation to the root of the API
  • its position is relative to link relations
  • retrieving a representation is retrieved relative to the link relations of the context (and default context is root of the API)

It is quite easy to loose control of this part of the code. One recommendation is to create separate code that uses link relations (the tip here is that semantic link cache import is never in a Vue component). This has multiple benefits: improves understanding of domain (link relations), avoids duplication, improves composition (reusability), improves its changeability and, finally, makes it independently testable. Enough, some code!

Client routing will now occur and load up a client view. The apiUri always injected into views (by convention of the router).

Writing the code that walks the network of data is where you need to have the API diagram at hand. A todo list falls in the root > me > todos > todos. But it is a little more complicated because there are singletons (me), named collections and collections of collections in there too. Read through the code and also look at the API itself and see if you can figure it out. This is as hard as it gets! Just note that we not dealing with the semantics of (HTTP) network requests at this level. It is all dealt with in the semantic-network code.

see here

Unlock the next chapter
An application cache
Is a global, single version of what the clients has loaded
Requires that the developers access resources though link relations
Allows binding the UI to representations
All of the above