我已經安裝了一個應用程序,它在Opera和Firefox上運行得非常棒,但是在Google Chrome瀏覽器中緩存了AJAX請求,並且會顯示過時的數據!阻止Chrome緩存AJAX請求
http://gapps.qk.com.au是應用程序。在Chrome中運行時,它甚至不會發送AJAX請求,但在其他瀏覽器中嘗試時,它始終會執行AJAX請求並返回數據。
是否有任何方法(Apache/PHP/HTML/JS)阻止Chrome執行此操作?
的AJAX調用:
function sendAjax(action,domain,idelement) {
//Create the variables
var xmlhttp,
tmp,
params = "action=" + action
+ "&domain=" + encodeURIComponent(domain)
xmlhttp = new XMLHttpRequest();
//Check to see if AJAX request has been sent
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
$('#'+idelement).html(xmlhttp.responseText);
}
};
xmlhttp.open("GET", "ajax.php?"+params, true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
//console.log(params);
xmlhttp.send(params);
}
sendAjax('gapps','example.com','gapps');
什麼是PHP腳本返回的頭文件?確保他們不允許緩存,並返回適當的內容類型。 – mariusnn 2012-07-13 03:30:48