0

I am getting 304 status code through a angular JS webApi get request only using IE11. When I press Ctrl+F5, it corrects and get 200 status code (which is correct behavior). It works fine using Chrome. I am using following code.

factory('StudentService', function ($q, $http, pathProvider, searchParams, student) {
return {
    getStudents: function (successcb) {
        var deferred = $q.defer();
        var url = pathProvider.getPath("Student/GetStudents");
        $http({
            method: 'GET'
            , url: url
            , cache:false
        }).
            success(function (data, status, headers, config) {
                deferred.resolve(data);
            }).
            error(function (data, status, headers, config) {
                deferred.reject(status);
                alert('getStudents ' + status + ': ' + data);
            });
        return deferred.promise;
    }
}

It appears IE has some problem.

Thanks

Dansih Salam
  • 31
  • 2
  • 4

1 Answers1

4

IE probably adds a If-Modified-Since or If-None-Match request header to the request. If you press CTRL+F5, you force a browser refresh, which means that IE does not add these headers.

It seems that IE does not interpret the angular option cache:false very well. I don't know whether this is an IE or an angular issue, but you can resolve it in javascript by making sure the request is unique. For instance, by adding a dummy parameter to the query string:

    $http({
        method: 'GET'
        , url: url
        , cache:false
        , params: { 'foobar': new Date().getTime() }
    })

You can also fix this on the server by disallowing any browser caching. How you do that depends on the server technology you use.

Elian Ebbing
  • 18,779
  • 5
  • 48
  • 56