Open vicb opened 10 years ago
@vicb If we were to build a full featured cache, do you think it should be a part of Angular? From what I can see, there is nothing angular-specific about how the cache is used right now. So maybe writing a decorator for dom.HttpRequest.request
would be better. In this case, non Angular projects would be able to use it too.
It should definitely not be part of angular.
My idea is that the code we are looking for is probably already living somewhere in dart so apparently this is request.
Let me have a look at b/o next week and let's discuss the best way to do it.
Actually we should probably only rely on the browser cache. The current implementation is very naive and violates the http cache spec in many ways. What about removing the cache layer here ?
An other been benefit is that debugging would be much easier as all requests would appear in the dev tools
IMO using the browser cache should be OK. So I think removing the cache layer, at least for now, is a good approach. BTW, AngularJS has the same naive implementation of cache.
How much slower is getting something from the browser cache? You need to switch out of the VM, which will result in an extra Scope.apply().
I would love to see numbers, though.
AngularJS has this same problem, the cache policy is horrible and generally broken.
+1 for a separate, compliant caching module. This is fairly low priority at the moment: most apps that I know of implement their own data RPC system and don't use this cache for anything with complicated caching requirements.
On Sat, May 31, 2014 at 7:31 AM, Victor Savkin notifications@github.com wrote:
IMO using the browser cache should be fine.
— Reply to this email directly or view it on GitHub https://github.com/angular/angular.dart/issues/1076#issuecomment-44749727 .
I think there are 2 separate concerns here: functionality and performance.
There is no way to fix the bugs of the current implementation with the current interface. A proper cache should have a request as input and not an URL (to access the headers). Then I propose that we start by dropping the current cache asap.
I have to think more about the perf. I don't really see how we can avoid an apply after each single request (don't this assume that only requests can update the data ?). For sure dropping the cache would save memory.
On June 1, 2014 5:39:00 PM CEST, James deBoer notifications@github.com wrote:
How much slower is getting something from the browser cache? You need to switch out of the VM, which will result in an extra Scope.apply().
I would love to see numbers, though.
AngularJS has this same problem, the cache policy is horrible and generally broken.
+1 for a separate, compliant caching module. This is fairly low priority at the moment: most apps that I know of implement their own data RPC system and don't use this cache for anything with complicated caching requirements.
On Sat, May 31, 2014 at 7:31 AM, Victor Savkin notifications@github.com wrote:
IMO using the browser cache should be fine.
— Reply to this email directly or view it on GitHub
https://github.com/angular/angular.dart/issues/1076#issuecomment-44749727 .
Reply to this email directly or view it on GitHub: https://github.com/angular/angular.dart/issues/1076#issuecomment-44780614
My experiments showed that using the browser cache is about 8 times slower (which is about 3ms per request). I think 3ms is fine, cause we are not talking about any real-time data here (it would not be cached anyways).
I agree with @vicb that the current cache should be dropped. It is basically broken and can cause some hard to troubleshoot bugs.
:+1: to drop the current cache. IMO 3ms should not be compared with a in-memory cache but to the HTTP round trip time (worst case).
We could also add provision for a TBD cache system (as the API is known).
I can submit a PR dropping the cache.
That would be great
IIUC, templates are cached using the Http cache, so 3ms * 1000s of template lookups is a deal-breaker.
That's a very good point.
Right now, TemplateCache is used like this:
http.get(cssUrl, cache: templateCache)
Can we change it, so it is used like this?
templateCache.get(cssUrl)
Where templateCache can use the Http service to get the data, and then cache it (as a String, not an HttpResponse).
IMO it leads to a few nice things:
First, since we do not cache http responses, but templates, we do not have to follow the http spec. So we can use the naive caching we have today (templates do not get changed anyways).
Second, it makes preloading templates less confusing. Cause right now if I have something like this in an html file:
<template id="my_template.html" type="text/ng-template">
My Template
</template>
It will be cached as an http response, though no requests have been made.
Http
has the following code:I think there are several issues here:
References: