1、在服務端加 header("Cache-Control: no-cache, must-revalidate");(如php中)
2、在ajax發送請求前加上 anyAjaxObj.setRequestHeader("If-Modified-Since","0");
3、在ajax發送請求前加上 anyAjaxObj.setRequestHeader("Cache-Control","no-cache");
4、在 Ajax 的 URL 參數後加上 "?fresh=" + Math.random(); //當然這裏參數 fresh 可以任意取了
5、第五種方法和第四種類似,在 URL 參數後加上 "?timestamp=" + new Date().getTime();
6、用POST替代GET:不推薦 [POST的數據是不緩存的]
1、加個隨機數
xmlHttp.open("GET", "ajax.asp?now=" + new Date().getTime(), true);