简体   繁体   中英

cache:false in ajax call attach a value with URl

If I set AJAX cache to false using:

$.ajaxSetup ({
cache: false });

Then my resulting AJAX URL has the characters &_=1381901096821 added to the end so that the browser (especially IE) sees it as a new page request.

The resulting call is: eg =1381901096821">http://MyServer/authcheck?=1381901096821

But I don't want that value attached with the URL. Is there any way to remove it?

Thanks in advance.

You can set cache to true:

$.ajaxSetup ({
    cache: true
});

Then manually add no-cache headers:

$.ajaxSetup({
    beforeSend: function (xhr)
    {
        xhr.setRequestHeader("Cache-Control", "no-cache");
        xhr.setRequestHeader("Pragma", "no-cache");
    },
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM