[EMAIL PROTECTED] wrote:
> > That's what they are trying to tell you; how to cache the result of
> > the XSP, not the XSP itself (this is done automaticly by the Cocoon
> > caching pipeline)
> >
> > If you add the following code to your XSP, the result (not the XSP)
> > will be cached for 120 seconds:
> >
> > public SourceValidity getValidity() {
> > int validity = 120;
> > return new ExpiresValidity(validity * 1000);
> > }
> >
> > Add this in the /xsp:page/xsp:logic-element.
> >
> > Askild
> > -
>
> thnx askild
>
> this is exactly what i need but with one modification
> is it possible to turn cache ON/OFF manualy?
Great. Glad I could help! :)
There at least 2 possibilities, depending on what you want.
If you want to change this manually at the server, for debugging etc. you
can switch to a noncaching-pipeline (see <map:pipes>-section in root
sitemap)
If you need a more dynamic solution, and need this to be configurable from
the client, you can pass the timeout to the pipeline as a request parameter:
public SourceValidity getValidity() {
// keep in cache for our validity time
int validity = 120;
try {
validity =
Integer.valueOf(parameters.getParameter("validity")).intValue();
} catch(Exception e) {
// keep default value
}
return new ExpiresValidity(validity * 1000);
}
I guess that you must change the getKey()-method also:
public Serializable getKey()
{
try {
return "" + parameters.getParameter("pageKey");
} catch(Exception e) {
return "";
}
}
Sitemap snippet:
<map:generate type="serverpages" src="yourpage.xsp">
<map:parameter name="validity" value="{request:validity}"/>
<map:parameter name="pageKey" value="{request:validity}"/>
</map:generate>
This closely resembles an approach that I have been using with great success
:)
Askild
-
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]