cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gustavo Nalle Fernandes" <...@ig.com.br>
Subject RES: RES: Cache and HTMLGenerator
Date Tue, 30 Mar 2004 00:41:05 GMT
 Thanks for the code! It is indeed very simple! That?s why I like Cocoon :)
  Regarding the Last-Modified header, the getLastModified() do work for GET
request, but the GET request
also brings the whole document and not just the headers. That?s why I was
observing the whole document being
transferred all the time. So what is the best scenario for the
HTMLGenerator? Always do a HEAD request to see if the remote document is
modified and if it is, make a subsequent GET request OR always make a GET on
every request ? It depends of the size of the document and the modification
frequency. If the remote document is too large, it is inefficent to make a
GET all the time, as the HTMLGenerator does today. On the other hand, if the
document is modified frequently, it would be inefficient to make HEAD and
GET request, since it means making two connections to the remote site.Using
a sitemap parameter specifying the interval that the HTMLGenerator would
fectch data would address both issues. Do you think it is worthy to change
the current HTMLGenerator to include this extra parameter?

Gustavo

-----Mensagem original-----
De: Joerg Heinicke [mailto:joerg.heinicke@gmx.de]
Enviada em: segunda-feira, 29 de marco de 2004 21:16
Para: users@cocoon.apache.org
Assunto: Re: RES: Cache and HTMLGenerator


On 30.03.2004 01:54, Gustavo Nalle Fernandes wrote:

>  Interesting class Joerg. A couple of observations:
>
>  1) The remote site DO have Last-modified header and Cocoon is issuing a
GET
> request instead of a HEAD request
>  to obtain the header value. This is a common mistake made when using the
> java.net.HttpURLConnection class. If you
>  want to make a HEAD request, you must use setRequestMethod("HEAD") on
your
> HttpURLConnection class before calling
>  the method to obtain the header value.

Unfortunately this is out of my knowledge. You mean getLastModified()
would not work on a GET request? But aren't the header sent to on a GET
request?

>  2) Regarding your implementation, I found very promising the idea of
> creating a subclassed HTMLGenerator that
>  enables us to control the cache timeout. I am kind of a newbie in cocoon
> source code, so could you
>  provide me general guidelines on how could I create a external sitemap
> parameter to manage this time interval? It would
>  replace the hard coded value "10000" in your code.

Also easy :) The HTMLGenerator has some examples for this, e.g. xpath
parameter:   xpath = par.getParameter("xpath", null);
The first one is the parameter name, the second one the default value.


The class could then look like:

public class DelayedHTMLGenerator extends HTMLGenerator {

    protected int delay;

    public void setup(SourceResolver resolver, Map objectModel,
                      String src, Parameters par)
    throws ProcessingException, SAXException, IOException {
      super.setup(resolver, objectModel, src, par);

      delay = par.getParameterAsInteger("delay", 1000);

      this.inputSource =
             new DelayedRefreshSourceWrapper(this.inputSource, delay);
    }
}

You would specify it in the sitemap like the following:

<map:generate type="delayhtml" src="url">
   <map:parameter name="delay" value="10000"/>
</map:generate>

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message