Unexpected Caching of AJAX results in IE8

前端 未结 10 2161
走了就别回头了
走了就别回头了 2020-11-28 01:59

I\'m having a serious issue with Internet Explorer caching results from a JQuery Ajax request.

I have header on my web page that gets updated every time a user navig

10条回答
  •  独厮守ぢ
    2020-11-28 02:43

    IE is notorious for its aggressive caching of Ajax responses. As you're using jQuery, you can set a global option:

    $.ajaxSetup({
        cache: false
    });
    

    which will cause jQuery to add a random value to the request query string, thereby preventing IE from caching the response.

    Note that if you have other Ajax calls going on where you do want caching, this will disable it for those too. In that case, switch to using the $.ajax() method and enable that option explicitly for the necessary requests.

    See http://docs.jquery.com/Ajax/jQuery.ajaxSetup for more info.

提交回复
热议问题