0

I have a problem with angular.js ajax call with IE. The first time I do the request, all is working good (I get the good result). But when I do an other ajax call (same request) without refreshing the page, the result look to be the same as the first call, even if it shouldn't be the same.

Here's how my request look like :

this.getemploye = function (isaftersave) {
    $http({
        url: 'Contact.svc/getemployee',
        method: "GET"
    }).success(function (data) {
        //The data result is always the same with IE.
    });

};

Note that I have no problem with Chrome and FireFox. The version of IE is 11.

1 Answer 1

2

IE will aggressively cache all ajax calls (actually pretty much everything). You will need to set the cache options on the HTTP response headers from your servers.

You will need to add the Cache-Control header to your ajax response sent from the server if you do not want it cached.

Cache-Control: no-cache, no-store

As an extra measure you should set cache:false in your $http call

$http.get('https://api.myapp.com/someresource', { cache: false });

If you haven't got access to modify the server you could always just append a random query string onto the url every time This will force IE to re-issue the request as it won't have seen that url before.

this.getemploye = function (isaftersave) {
    $http({
        url: 'Contact.svc/getemployee?nocache=' + new Date().toISOString(),
        method: "GET"
    }).success(function (data) {
    });

};
Sign up to request clarification or add additional context in comments.

1 Comment

'Contact.svc/getemployee?nocache=' + new Date().toISOString()' worked like a charm ! thank you :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.