aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/http.js
diff options
context:
space:
mode:
authorAlexander Shtuchkin2013-02-28 09:25:21 +0400
committerJames deBoer2013-03-08 10:19:18 -0800
commit99f3b70b2d316f5bb39e21249e752c29f49c90ab (patch)
tree6d45c16c42bd3deda361822efe3b9b37391f1e29 /src/ng/http.js
parent603fe0d19608ffe1915d8bc23bf412912e7ee1ac (diff)
downloadangular.js-99f3b70b2d316f5bb39e21249e752c29f49c90ab.tar.bz2
feat(http): set custom default cache in $http.defaults.cache
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 #2079
Diffstat (limited to 'src/ng/http.js')
-rw-r--r--src/ng/http.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ng/http.js b/src/ng/http.js
index 99c1fff3..e4d695c4 100644
--- a/src/ng/http.js
+++ b/src/ng/http.js
@@ -306,6 +306,9 @@ function $HttpProvider() {
* cache, but the cache is not populated yet, only one request to the server will be made and
* the remaining requests will be fulfilled using the response for the first request.
*
+ * A custom default cache built with $cacheFactory can be provided in $http.defaults.cache.
+ * To skip it, set configuration property `cache` to `false`.
+ *
*
* # Response interceptors
*
@@ -733,8 +736,10 @@ function $HttpProvider() {
promise.then(removePendingReq, removePendingReq);
- if (config.cache && config.method == 'GET') {
- cache = isObject(config.cache) ? config.cache : defaultCache;
+ if ((config.cache || defaults.cache) && config.cache !== false && config.method == 'GET') {
+ cache = isObject(config.cache) ? config.cache
+ : isObject(defaults.cache) ? defaults.cache
+ : defaultCache;
}
if (cache) {