By default XSP generated by Cocoon are not cached, and executed on every request.
To change this behaviour, you need to add these two methods:

<xsp:page language="java" xmlns:xsp="http://apache.org/xsp";>
<xsp:logic>
  public long generateKey(){
      // Unique ID of your page
      return HashUtil.hash(getClass().getName());
  }
  public CacheValidity generateValidity(){
      // Modify according to your needs
      return new NOPCacheValidity();
  }
</xsp:logic>

If you add snippet shown above, your XSP would be executed ONLY ONCE and cached 
FOREVER by Cocoon.
Another example of validity method is:

  public CacheValidity generateValidity(){
      if(changed) return null;
      return new NOPCacheValidity();
  }

This would invalidate cache entry every time you decide (using if() statement) to 
re-generate XSP.

Vadim

> -----Original Message-----
> From: Paolo [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 24, 2001 10:42 AM
> To: Cocoon-Users; [EMAIL PROTECTED]
> Subject: Pipeline caching...
> 
> 
> I am working on a web application bases on Cocoon 2. Every page of my
> application has to be created by applying a stylesheet to many
> aggregated pipelines. Some of these are generated by XSP and querying
> databases.
> 
> Some of these XML components don't change into a session, then I can
> generate them the first time only, store somewhere and reload them fast
> without reprocess every pipeline during the session.
> 
> I trying using the WriteDOM/ReadDOM transformers but I really don't know
> how to use that because of their transformer-nature (how can use a
> stored DOM tree as generator?).
> 
> What I am asking is simple: is there any way to cache a pipeline in this
> way, simply by adding a parameter to the pipeline definition instead of
> many selectors/transformers to do that?
> 
> Is there anyone that is working on a feature like that?
> 
> This is my sitemap:
> 
> <!-- HOME PAGE -->
> <map:match pattern="home_*">
>   <map:aggregate element="gportal">
>     <map:part src="cocoon:/dbhotel"/>         <!-- fixed in session
> -->
>     <map:part src="cocoon:/dbroom"/>          <!-- fixed in session
> -->
>     <map:part src="cocoon:/dbcustomer"/>              <!-- fixed in
> session -->
>     <map:part src="cocoon:/dbdays"/>          <!-- fixed in session
> -->
>     <map:part src="cocoon:/otherpipelines"/>  <!-- changes in session
> -->
>   </map:aggregate>
>   <map:transform src="documents/{1}/home.xsl"/>
>   <map:serialize/>
> </map:match>
> 
> Where dbhotel, dbroom and dbcustomer are something like:
> 
> <map:match pattern="dbroom">
>   <map:generate src="documents/shared/xsp/dbroom.xsp"
> type="serverpages"/>
>   <map:serialize type="xml"/>
> </map:match>
> 
> What do you think about that?
> 
> Thanx,
> Paolo Scaffardi
> AIRVENT SAM S.p.A.
> 
> 
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> 
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>
> 
> 

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to