<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer" nil="true"></assigned-user-id>
  <attachments-count type="integer">0</attachments-count>
  <closed type="boolean">false</closed>
  <created-at type="datetime">2009-07-23T03:15:55+02:00</created-at>
  <creator-id type="integer">50818</creator-id>
  <milestone-due-on type="datetime" nil="true"></milestone-due-on>
  <milestone-id type="integer" nil="true"></milestone-id>
  <number type="integer">723</number>
  <permalink>ajaxperiodicalupdater-and-http-cache-control</permalink>
  <priority type="integer">0</priority>
  <project-id type="integer">8886</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>new</state>
  <tag>section:ajax</tag>
  <title>Ajax.PeriodicalUpdater and http cache control</title>
  <updated-at type="datetime">2009-11-16T16:50:26+01:00</updated-at>
  <user-id type="integer">32948</user-id>
  <user-name>T.J. Crowder</user-name>
  <creator-name>bubbatls</creator-name>
  <url>http://prototype.lighthouseapp.com/projects/8886/tickets/723</url>
  <original-body>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&gt;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.</original-body>
  <latest-body>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&gt;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.</latest-body>
  <original-body-html>&lt;div&gt;&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;This would be an Improvment in performance if the request was
not done or when no change the update of html was not done.&lt;/p&gt;
&lt;p&gt;to do this well I've made a class like that : @@@javascript
Ajax.Ressource = Class.create({
initialize:function(uri,options){&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;this.uri = uri;
this.options = options;
this.headers={};
this.refresh();
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;}, dontRefreshBefore:new Date(0), refresh:function(){&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;if(this.dontRefreshBefore&amp;gt;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);
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;}&lt;br&gt;
});&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;

and my own Updater using this Ajax.Ressource.

But maybe its worth being putted in prototype and in the PeriodicalUpdater.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>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&gt;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.</body>
      <body-html>&lt;div&gt;&lt;p&gt;if the server (as mine) use the http cache control headers like
Etag/Last-Modified/Expires&lt;br&gt;
The PeriodicalUpdater don't care and update the html with its old
value.&lt;/p&gt;
&lt;p&gt;This would be an Improvment in performance if the request was
not done or when no change the update of html was not done.&lt;/p&gt;
&lt;p&gt;to do this well I've made a class like that :&lt;br&gt;
@@@javascript Ajax.Ressource = Class.create({&lt;br&gt;
initialize:function(uri,options){&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;this.uri = uri;
this.options = options;
this.headers={};
this.refresh();&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;}, dontRefreshBefore:new Date(0), refresh:function(){&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;if(this.dontRefreshBefore&amp;gt;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);&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;}&lt;br&gt;
});&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
and my own Updater using this Ajax.Ressource.&lt;br&gt;
&lt;br&gt;


&lt;br&gt;
But maybe its worth being putted in prototype and in the PeriodicalUpdater.&lt;/code&gt;
&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-06-24T17:42:10+02:00</created-at>
      <creator-id type="integer">50818</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">723</number>
      <permalink>ajaxperiodicalupdater-and-http-cache-control</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8886</project-id>
      <state>new</state>
      <tag>ajax ajax.periodicalupdater etag expires http last-modified</tag>
      <title>Ajax.PeriodicalUpdater and http cache control</title>
      <updated-at type="datetime">2009-06-24T17:42:13+02:00</updated-at>
      <user-id type="integer">50818</user-id>
      <user-name>bubbatls</user-name>
      <creator-name>bubbatls</creator-name>
      <url>http://prototype.lighthouseapp.com/projects/8886/tickets/723</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>[not-tagged:&quot;ajax&quot; tagged:&quot;section:ajax&quot; bulk edit command]</body>
      <body-html>&lt;div&gt;&lt;p&gt;[not-tagged:&quot;ajax&quot; tagged:&quot;section:ajax&quot; bulk edit command]&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-07-24T01:54:23+02:00</created-at>
      <creator-id type="integer">50818</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: ajax ajax.periodicalupdater etag expires http last-modified
</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">723</number>
      <permalink>ajaxperiodicalupdater-and-http-cache-control</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8886</project-id>
      <state>new</state>
      <tag>section:ajax</tag>
      <title>Ajax.PeriodicalUpdater and http cache control</title>
      <updated-at type="datetime">2009-07-24T01:54:23+02:00</updated-at>
      <user-id type="integer">14168</user-id>
      <user-name>Tobie Langel</user-name>
      <creator-name>bubbatls</creator-name>
      <url>http://prototype.lighthouseapp.com/projects/8886/tickets/723</url>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>[responsible:none bulk edit command]</body>
      <body-html>&lt;div&gt;&lt;p&gt;[responsible:none bulk edit command]&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-11-16T16:50:26+01:00</created-at>
      <creator-id type="integer">50818</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer" nil="true"></milestone-id>
      <number type="integer">723</number>
      <permalink>ajaxperiodicalupdater-and-http-cache-control</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8886</project-id>
      <state>new</state>
      <tag>section:ajax</tag>
      <title>Ajax.PeriodicalUpdater and http cache control</title>
      <updated-at type="datetime">2009-11-16T16:50:26+01:00</updated-at>
      <user-id type="integer">32948</user-id>
      <user-name>T.J. Crowder</user-name>
      <creator-name>bubbatls</creator-name>
      <url>http://prototype.lighthouseapp.com/projects/8886/tickets/723</url>
    </version>
  </versions>
</ticket>
