cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Nock" <pn...@medicineplanet.com>
Subject RE: XSP: caching?
Date Mon, 07 May 2001 16:37:31 GMT
Don't know if this helps, but I had issues with 1.8.n caching and found that
the resulting xsp:structure/util:cacheable wasn't matching in the util
logicsheet when I put
<xsp:structure>
        <util:cacheable/>
</xsp:structure>
under an <xsp:page> tag in my source file.

As a workaround I added an explicit <apply-templates> for it in the util
logicsheet though, and also added the hasChanged code to the util:cacheable
template and this seems to work pretty well.

Here's my new part of the util.xsl stylesheet:

================================================
  <xsl:template match="xsp:page">
    <xsp:page>
      <xsl:apply-templates select="@*"/>

      <xsp:structure>
        <xsp:include>java.net.URL</xsp:include>
        <xsp:include>java.util.Date</xsp:include>
        <xsp:include>java.text.SimpleDateFormat</xsp:include>
      </xsp:structure>

***** added this ****     <xsl:apply-templates
select="xsp:structure/util:cacheable"/> ****
      <xsl:apply-templates/>
    </xsp:page>
  </xsl:template>

  <!-- Mark page as cacheable -->
  <xsl:template match="xsp:structure/util:cacheable">
    <xsp:logic>
      public boolean isCacheable (HttpServletRequest request) {
        return true;
      }

     static long last_changed_millis = 0;
     static final long MILLISECONDS_TO_CACHE = 5*60*1000;

     public boolean hasChanged(Object context) {
       long current_millis = System.currentTimeMillis();
       if (current_millis - MILLISECONDS_TO_CACHE &gt; last_changed_millis)
{
         last_changed_millis = current_millis;
         return true;
       } else {
         return false;
       }
     }
    </xsp:logic>
  </xsl:template>
....


Although, I don't use caching though right now since:
1. I don't need to...
2. I found that only the first page I loaded after Cocooon startup was ever
cached, which wasn't much help.  Never really looked if this was a bug or a
configuration issue.
So I'm not sure if this is un-necessary in later 1.8.3 versions.

Paul


-----Original Message-----
From: Tony [mailto:tony@employer.com.br]
Sent: Friday, May 04, 2001 12:27 PM
To: cocoon-users@xml.apache.org
Subject: RE: XSP: caching?


> funny, in your source code, you have these lines:
>
>      public boolean isCacheable (HttpServletRequest request)
> {return false;}
>      public boolean hasChanged (Object context) {return true;}
>
> that is to say, exactly the opposite.


That's right, my attached XML was messed up. But Cocoon 1.8.2 dosen't seem
to care about it as much as you do anyway, since this order doesn't change a
damn thing .
;)

Looking at the list I'm obviousely not the only one having such troubles. A
solution to all this will make me sleep a lot better. Maybe Cocoon 1.8.3 ?


Tony.






---------------------------------------------------------------------
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: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


---------------------------------------------------------------------
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: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message