-
Notifications
You must be signed in to change notification settings - Fork 27.5k
$http cache invalidation API #2079
Comments
I believe HTTP cache has nothing to do with this issue. He asks about Angular's own http cache. Current workaround: use custom cache (use $cacheFactory to create it and provide it as |
I do like the #2084 approach, which would make $http's cache invalidation possible. I'm still not convinced it is a good idea, because the app developer would need to set the HTTP headers for the request to ensure the request made it back to the origin server. |
Aren't HTTP cache headers set by server side? |
The client has some control, mainly through setting "max-age: 0" and setting the "If-Modified-Since" header.. c.f. http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.1.6 Angular's $http cache is not HTTP-compliant. (e.g. doesn't respect age headers). It probably should be. |
Thanks James, I wasn't aware of that. So, making Angular's $http cache HTTP-compliant could be another pull request :) Anyway, in current state, the app developer can ensure that specific urls are not cached (that's what @spolu was asking for originally) by providing headers from server. This is the main cache controlling mechanism in HTTP. Having done that, app developer doesn't need to provide any additional client headers, correct me if I'm wrong. Having said that, I would not use $http cache at all, as the browser usually does a good job caching requests and all the HTTP cache headers are there for a reason. |
When we need more control over http caching, we may want to provide a custom cache to be used in all http requests by default. To skip default cache, set {cache: false} in request configuration. To use other cache, set {cache: cache} as before. See angular#2079
When we need more control over http caching, we may want to provide a custom cache to be used in all http requests by default. To skip default cache, set {cache: false} in request configuration. To use other cache, set {cache: cache} as before. See angular#2079
It would greatly extend the use of the $http cache mechanism if we could invalidate the cache content for a specific URL so that any subsequent request on that URL would go the the actual server:
The text was updated successfully, but these errors were encountered: