cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
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.

  <xsp:logic>
    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.
  </xsp:logic>

  <mypage>
    <xsp:logic>
      if (cachedElement == null) {
        cachedElement = generateElement ();
        // your method to create content.
      }
    </xsp:logic>
    <xsp:expr>cachedElement</xsp:expr>
    <util:counter/>
  </mypage>

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.

--
Robin


Hans-Guenter Stein <Hans-Guenter.Stein@siteos.de> 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: 
>There
>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 
>set
>'hasChanged' to 'false', the page gets cached, but the counter won't work
>anymore.
>
>Thanks,
>Hans-Guenter
>
>Robin Green wrote:
>
> > That's what Cocoon does by default. Ensure that caching is turned on in 
>all
> > copies of cocoon.properties. 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 
>the
> > 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 
>(which
> > Xalan does).
> >
> > --
> > Robin
> >

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


Mime
View raw message