This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
$http : ability to clear a request from the cache #5968
Milestone
Comments
njs50
added a commit
to njs50/angular.js
that referenced
this issue
Feb 19, 2014
…e a request overwrite an existing value in the cache angular#5968
njs50
added a commit
to njs50/angular.js
that referenced
this issue
Feb 19, 2014
…ests in $http cache Adds $http.removeCache method. Adds/implements replaceCache property in $http request configuration. Closes angular#5968
njs50
added a commit
to njs50/angular.js
that referenced
this issue
Feb 19, 2014
…ests in $http cache Adds $http.removeCache method. Adds/implements replaceCache property in $http request configuration. Closes angular#5968
njs50
added a commit
to njs50/angular.js
that referenced
this issue
Mar 3, 2014
…ests in $http cache Adds $http.removeCache method. Adds/implements replaceCache property in $http request configuration. Closes angular#5968
njs50
added a commit
to njs50/angular.js
that referenced
this issue
Nov 17, 2014
…ests in $http cache Adds $http.removeCache method. Adds/implements replaceCache property in $http request configuration. Closes angular#5968
njs50
added a commit
to njs50/angular.js
that referenced
this issue
Nov 17, 2014
…ests in $http cache Adds $http.removeCache method. Adds/implements replaceCache property in $http request configuration. Closes angular#5968
njs50
added a commit
to njs50/angular.js
that referenced
this issue
Nov 17, 2014
…ests in $http cache Adds $http.removeCache method. Adds/implements replaceCache property in $http request configuration. Closes angular#5968
@njs50 Take a look to https://github.com/angular-hu/angular-hu/tree/develop/src/headers . I'm using it to remove requests from the cache |
@jmendiara that looks handy, my issue is more that I don't think it's a good idea to have a cache where you can't remove things without having to modify/decorate the core code in some way. currently I do both:
(1) is usually in response to something that happened on a remote system and (2) is in reaction to something the user has done. |
@njs50 Agree, httpu.headers gives you the cache key for a specific request, so the controlller/service can invalidate them. It's a foundation to implement your specific app business logic. $http.get('/api', {
cache: myCacheImpl
})
.then(function(response) {
$scope.cacheKey = response.headers('httpu-request-url'); //store to react on user action (2)
})
.catch(function(rejection) {
if (rejection.data.error) { //your app condition for (1)
rejection.config.cache.remove(rejection.headers('httpu-request-url')); //or directly myCacheImpl
}
}); You can also take a look to httpu.urlbuilder to re-calculate the request-url. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
At the moment there isn't a direct way in
$http
to clear the cache.I know it's possible to use
$cacheFactory
to return the default or custom cache.However to be able to use this with 100% confidence i'd also need the
buildUr
l function from$http
exposed to generate the key.so it'd be nice if we had either:
$http.buildUrl(url,params)
made publicor something like:
If either of those sounds like they'd be a good idea I'm happy to put together a PR for it...
The text was updated successfully, but these errors were encountered: