cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <>
Subject cache madness
Date Thu, 10 Aug 2000 01:22:38 GMT
just a quick note before i leave. i'm getting ready to deploy my biggest
cocoon site ever (nothing really exciting, but i'll post an URL once the
students have had a chance to whack on it for a while).

i hadn't bothered adding cache support to my XSP pages yet - it was
running along smoothly enough without it, i figured why bother. just for
grins, though, i just added to my central logicsheet this method:

<xsl:template match="xsp:page">
  <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
    static long last_changed_millis = 0;
    static final long MILLISECONDS_TO_CACHE = 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;

(stefano will recognize this as the Return of the Timeout Cache and clutch
his head. whatever - i still say it's a fine cache for the results of
database queries that aren't time critical.) anyway, i went from 40-60
seconds to process 100 requests to 3-4 seconds. that's over an order of
magnitude improvement in performance for 10 minutes of work. sheesh. teach
me to be so lazy.

anyway, for those of you craving a little bit more speed from your XSP
pages, this little trick'll knock your socks off. i would almost suggest
adding an optional attribute to the xsp:page element, say, cache="60",
which would include a variant on this method in the xsp generated classes

- donald

View raw message