cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <>
Subject Re: Caching in cocoon
Date Tue, 04 Jul 2000 11:42:55 GMT
Cocoon doesn't really help you here. You'd have to write your own Java code 
to cache parts of a page. E.g.

    private static Element cachedElement = null;
    // can't add DocumentFragments with <xsp:expr> due to a bug in
    // 1.7.4 - I will post a patch for this soon -
    // so have to use whole Elements instead.

      if (cachedElement == null) {
        cachedElement = generateElement ();
        // your method to create content.

The fact that the cachedElement belongs to a different DOM Document should 
not matter IIRC because <xsp:expr> always recreates elements passed to it 
under the current document.

You could then write a logicsheet for this so that it could be modularised 
in one place.


Hans-Guenter Stein <> wrote:
>One more question: is there any strategy you could think of to cache 
>'parts' of
>a complex page and have others be processed on every request? Example: 
>might be a page with a lot of content plus a hit-counter (e.g. the
><util:counter/> from the lib included in the cocoon-distribution). When I 
>'hasChanged' to 'false', the page gets cached, but the counter won't work
>Robin Green wrote:
> > That's what Cocoon does by default. Ensure that caching is turned on in 
> > copies of Note that if using XSP, XSP pages are not
> > cached unless you include a method as follows:
> >
> >   <xsp:logic>
> >     public boolean hasChanged (Object context) {
> >       // return true here if the page content might have changed, or
> >       // false if it is safe to use a cached copy.
> >     }
> >   </xsp:logic>
> >
> > inside the <xsp:page> element, but outside your own root element. For 
> > hasChanged() method to work, you will need a recent release of Cocoon.
> >
> > Also, if you are using <?xsp:logicsheet?> you could switch to
> > namespace-mapped logicsheets instead, because these are automatically
> > "precompiled" on startup if the transformer (e.g. Xalan) supports it 
> > Xalan does).
> >
> > --
> > Robin
> >

Get Your Private, Free E-mail from MSN Hotmail at

View raw message