Prevent browser from caching AJAX requests

前端 未结 4 767
小鲜肉
小鲜肉 2020-12-08 04:52

I\'ve setup an app and it works fantastic on Opera and Firefox, but on Google Chrome it caches the AJAX request and will give stale data!

http://gapps.qk.com.au is t

4条回答
  •  旧时难觅i
    2020-12-08 05:51

    I was using jQuery ajax request when I ran into this problem.

    According to jQuery API adding "cache: false" adds a timestamp like explained in the accepted answer:

    This only works with GET and HEAD requests though but if you're using POST the browser doesn't cache your ajax request anyways. There's a but for IE8, check it out in the link if needed.

    $.ajax({ 
    type: "GET",
    cache: false, 
    });
    

提交回复
热议问题