I'm for combination.
I think we should have some global caching solution. And the best option
would be 3. We used to have similar caching in my previous company, so if
you want, I could help you with that.
David
On Wed, Dec 14, 2016 at 11:03 AM, Ondrej Zizka <ozizka(a)redhat.com> wrote:
 Hi team,
 regarding graph REST HTTP requests caching - should it be global or
 rather per-vertex (per-model)?
 I started coding a global solution. If another model needs the same
 data, it will request from the same URL. I see no reason not to return
 the same object.
 Another question is what to cache. Due to how it's currently done, the
 getter is supposed to return Observable<...Model>. There are these options:
 1) To cache an Observable which will wrap HTTP Observable. I don't know
 yet whether this will cause re-sending HTTP request for another
 subscriber. It will solve the Angular's change scanning, though, which
 is the bigger problem. Also,  RxJS's cache() operator could be used to
 cache the HTTP response internally.
 2) It can also resolve the Observable chain, and store the result into
 the cache asynchronously.
      So - when Angular would ask soon after, it would result in another
 request (maybe?); when called later, it would return the already
 available cached result.
      This would reduce the HTTP requests,  but would not necessarily
 solve the Angular change scanning.
 3) A combination of 1) and 2), which would cache
       * the Observables from 1) internally, so that the getter gets the
 same object each time,
       * the results from 2) so that the subsequent requests to the same
 URL don't generate another HTTP request, with some timeout so the page
 won't get staled.
       This one is a bit complicated but I think with some RxJS magic it
 can be done.
 Ondra
 --
 --
 Ondrej Zizka, Windup project, Brno
 _______________________________________________
 windup-dev mailing list
 windup-dev(a)lists.jboss.org
 
https://lists.jboss.org/mailman/listinfo/windup-dev