<div dir="ltr">I&#39;m for combination.<div><br></div><div>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.</div><div><br></div><div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 14, 2016 at 11:03 AM, Ondrej Zizka <span dir="ltr">&lt;<a href="mailto:ozizka@redhat.com" target="_blank">ozizka@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi team,<br>
<br>
regarding graph REST HTTP requests caching - should it be global or<br>
rather per-vertex (per-model)?<br>
I started coding a global solution. If another model needs the same<br>
data, it will request from the same URL. I see no reason not to return<br>
the same object.<br>
<br>
<br>
Another question is what to cache. Due to how it&#39;s currently done, the<br>
getter is supposed to return Observable&lt;...Model&gt;. There are these options:<br>
<br>
1) To cache an Observable which will wrap HTTP Observable. I don&#39;t know<br>
yet whether this will cause re-sending HTTP request for another<br>
subscriber. It will solve the Angular&#39;s change scanning, though, which<br>
is the bigger problem. Also,  RxJS&#39;s cache() operator could be used to<br>
cache the HTTP response internally.<br>
<br>
2) It can also resolve the Observable chain, and store the result into<br>
the cache asynchronously.<br>
     So - when Angular would ask soon after, it would result in another<br>
request (maybe?); when called later, it would return the already<br>
available cached result.<br>
     This would reduce the HTTP requests,  but would not necessarily<br>
solve the Angular change scanning.<br>
<br>
3) A combination of 1) and 2), which would cache<br>
      * the Observables from 1) internally, so that the getter gets the<br>
same object each time,<br>
      * the results from 2) so that the subsequent requests to the same<br>
URL don&#39;t generate another HTTP request, with some timeout so the page<br>
won&#39;t get staled.<br>
      This one is a bit complicated but I think with some RxJS magic it<br>
can be done.<br>
<br>
Ondra<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
--<br>
Ondrej Zizka, Windup project, Brno<br>
<br>
______________________________<wbr>_________________<br>
windup-dev mailing list<br>
<a href="mailto:windup-dev@lists.jboss.org">windup-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/windup-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/windup-dev</a><br>
</font></span></blockquote></div><br></div>