问题
I have an angular controller that makes repeated gets via the $http object, like this:
$scope.refresh = function()
{
let url = 'api/get-status';
$http.get( url ).then( function( response )
{
console.log( response.data );
});
};
$scope.intervalFunction = function()
{
$timeout( function()
{
$scope.refresh();
$scope.intervalFunction();
}, 2000 ) // msec
};
$scope.refresh();
$scope.intervalFunction();
The fetches appear to happen. When I do this in chrome I see the results coming back as expected in the console - except the result is just a repeat of the same content I get from the first result.
Whats extra inexplicable is I can turn off the server and the code continues to run without errors. When I look in the chrome's network view, chrome claims its continuing to make successful calls to the server.
Its as if the browser itself is returning cached results and lying about the fetches its making.
来源:https://stackoverflow.com/questions/36346796/calling-http-get-multiple-times-always-returns-cached-result