You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
To enable caching, set the request configuration cache property to true (to use default cache) or to a custom cache object (built with $cacheFactory)
You can change the default cache to a new object (built with $cacheFactory) by updating the $http.defaults.cache property. All requests who set their cache property to true will now use this cache object.
If you set the default cache to false then only requests that specify their own custom cache object will be cached.
I'm confused by the default value. The doc doesn't specify this.
So I run $http.defaults.cache and gets undefined. So will it ignore all cache-control header? It seems that this is not true.
I have the following question:
If cache is true, it will follow the http cache-control header and store the cache in browser cache. Is this correct? If it's true but the server doesn't reply cache-control header, it won't cache.
If cache is false it won't cache even if the server reply cache-control header.
If it's a CacheFactory object, then the object will handle it. Also ignore the cache-control header.
The text was updated successfully, but these errors were encountered:
@Fonger I can sense confusion about how $http cache works in AngularJS atm. So, in short, it is a simple cache that doesn't inspect response headers. You simply tell it to cache responses and if it will do so if asked, regardless of the response content, headers etc. So the cache-control header has no effect on the AngularJS cache.
Does it clarify things? Would you be up to sending us a doc update PR with the clarification you would like to see in the docs?
Included changes:
* Point out that only GET & JSONP requests are cached.
* Explain that the URL+search params are used as cache keys (headers not considered).
* Add note about cache-control headers on response not affecting Angular caching.
* Mention `$httpProvider.defaults.cache` (in addition to `$http.defaults.cache`).
* Clear up how `defaults.cache` and `config.cache` are taken into account for determining the
caching behavior for each request.
Fixes#11101Closes#13003
Included changes:
* Point out that only GET & JSONP requests are cached.
* Explain that the URL+search params are used as cache keys (headers not considered).
* Add note about cache-control headers on response not affecting Angular caching.
* Mention `$httpProvider.defaults.cache` (in addition to `$http.defaults.cache`).
* Clear up how `defaults.cache` and `config.cache` are taken into account for determining the
caching behavior for each request.
Fixes#11101Closes#13003
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
According to the docs,
it says
I'm confused by the default value. The doc doesn't specify this.
So I run
$http.defaults.cache
and getsundefined
. So will it ignore allcache-control
header? It seems that this is not true.I have the following question:
true
, it will follow the http cache-control header and store the cache in browser cache. Is this correct? If it'strue
but the server doesn't replycache-control
header, it won't cache.false
it won't cache even if the server replycache-control
header.The text was updated successfully, but these errors were encountered: