Ajax Prototype JQuery Caching Issue

>>俺个人意见,如果是经常变化的页面,可以用post去请求,或者一样发送头,从服务器上发送禁止cache的头比在js中发送if-modifed-since头使用更广泛。  
  >>还有哪个同志有空最好有完整测试一下,例如浏览器不同的设置、带有proxy(或者类似google的web加速器)的情况。。。

http://topic.csdn.net/t/20060306/13/4595412.html

Use POST or use a cache buster param in the query string. One sentence worth of content expanded into several blog posts and an article on Ajaxian… wow.
And btw, it has nothing to do with prototype.js, comments in his blog entries are oddly blaming it. Caching per unique URI is expected behavior with a GET.

function getContact(){
  var myvariables = “firstname=patrick&lastname=otten”;
  var mytime= “&ms=”+new Date().getTime();
  var url = “ajax/page.php?”+myvariables+mytime;
  xmlHttp.open(”GET”, url, true);
  xmlHttp.onreadystatechange = update;
  xmlHttp.send(null);
}

You may want to note that in prototype.js 1.6 you need to change

setRequestHeaders: function() {
var headers = {
‘X-Requested-With’: ‘XMLHttpRequest’,
‘X-Prototype-Version’: Prototype.Version,
‘Accept’: ‘text/javascript, text/html, application/xml, text/xml, */*’
};

to:

setRequestHeaders: function() {
var headers = {
‘If-Modified-Since’: ‘Thu, 1 Jan 1970 00:00:00 GMT’,
‘X-Requested-With’: ‘XMLHttpRequest’,
‘X-Prototype-Version’: Prototype.Version,
‘Accept’: ‘text/javascript, text/html, application/xml, text/xml, */*’
};


Prototype EXample

 var request = new Ajax.Request(sUrl,
  {
   method   :'get',
   onSuccess  :onSuccess,
   onFailure  :onFailure,
   parameters  :{vid:vehicleid,c:cc},
   requestHeaders :['Cache-Control','no-cache','Expires','0','If-Modified-Since','0']
  }
 );



你可能感兴趣的:(prototype)