This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
$http cache docs are not clear #11101
Closed
Description
According to the docs,
it says
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'strue
but the server doesn't replycache-control
header, it won't cache. - If cache is
false
it won't cache even if the server replycache-control
header. - If it's a CacheFactory object, then the object will handle it. Also ignore the cache-control header.