0

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.

Rafael Baptista
  • 11,181
  • 5
  • 39
  • 59
  • 2
    What does the server return in the expires and max-age headers? – twsaef Apr 01 '16 at 02:18
  • Yes, that is the problem. The headers tell the browser to cache the results. What is weird is that chrome network tab still considers these to be valid fetches with 200 status code and everything. – Rafael Baptista Apr 01 '16 at 02:25
  • I get 200's marked as 'from cache' in the size column as well. Have you tried disabling the cache in your network tab? – twsaef Apr 01 '16 at 02:46
  • I fixed it on the server end. it should not be setting cache headers. YOur insight was right on. – Rafael Baptista Apr 01 '16 at 02:50

0 Answers0