
Ajax.PeriodicalUpdater and http cache control
Reported by bubbatls | June 24th, 2009 @ 05:42 PM
if the server (as mine) use the http cache control headers like
Etag/Last-Modified/Expires
The PeriodicalUpdater don't care and update the html with its old
value.
This would be an Improvment in performance if the request was not done or when no change the update of html was not done.
to do this well I've made a class like that :
@@@javascript Ajax.Ressource = Class.create({
initialize:function(uri,options){
this.uri = uri;
this.options = options;
this.headers={};
this.refresh();
}, dontRefreshBefore:new Date(0), refresh:function(){
if(this.dontRefreshBefore>new Date()) return;
var opt = Object.extend({},this.options);
opt = Object.extend(opt,{
requestHeaders:this.headers,
onComplete:function(response,json){
this.headers['If-None-Match'] = response.getHeader('Etag');
this.headers['If-Modified-Since'] = response.getHeader('Last-modified');
var expire = response.getHeader('Expires');
if(expire){
var expirationdate = Date.parse(expire);
var now = Date.parse(response.getHeader('Date'));
this.dontRefreshBefore=new Date()+(expirationdate-now);
}
//TODO add header etag
if(response.status!=='304'){
this.options.onComplete(response,json);
}
}.bind(this)
});
new Ajax.Request(this.uri,opt);
}
});
and my own Updater using this Ajax.Ressource.
But maybe its worth being putted in prototype and in the PeriodicalUpdater.
Comments and changes to this ticket
-
Tobie Langel July 24th, 2009 @ 01:54 AM
- Tag changed from ajax, ajax.periodicalupdater, etag, expires, http, last-modified to section:ajax
[not-tagged:"ajax" tagged:"section:ajax" bulk edit command]
-
-
-
Witherspoon147 April 10th, 2018 @ 07:38 AM
Currently have an account as well as have no idea how to log in Musically Musically Login We have actually given all feasible methods that you deal with while Musically Register
-
Uposend255 April 11th, 2018 @ 10:56 AM
After that you need to take those steps toward your credit report karma account. creditkarmalogin.us Now you will certainly get the official website of Credit Karma.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
The Prototype JavaScript library.