1
In Angularjs, the $http
has a very useful option of caching the result of a request to a url
specific.
For example:
$scope.getUsers = function () {
return $http.get('/users', {cache: true})
}
$scope.getUsers().then( response => console.log(response.data)); // Faz a requisição
$scope.getUsers().then( response => console.log(response.data)); // Pega o cache, pois foi feita uma primeira requisição
But now I have a small need: I would like to know, when I receive an answer, if that answer came from a cache or not, and I did not find anything in the variable response
(which is returned in the parameter then
) that underlies this.
Is there any way in Angularjs to do that?