cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dafang Zhang <dafang.zh...@wcom.com>
Subject RE: xinclude caching (was: cache madness)
Date Thu, 31 Aug 2000 15:19:15 GMT
Hi, everyone,

I have to xinclude xml from remote site via URL and cache the xml for a
certain amount of time.  Using the strategy Donald described in his posting,
I can only cache the XSP page itself, but I also need to cache the xincluded
stuff within the XSP page for a specified period.

I noticed, in the archive, there's a proposal to add a timeout attribute to
the include element, but it seems not implemented yet.   Is there a way to
write my own java code to implement xinclude caching?  Do I need to modify
the hasChanged method in XIncludeProcessor.java?

Donald, would you explain what's the strategy for remote xml XInclude
caching?

	public boolean hasChanged(Object object) {
		/** I would have thought that the monitor would return false if the
		    key has no resources being monitored, but it doesn't. I think
		    that might should change, but we'll work around it for now. **/
		Object key = Utils.encode((HttpServletRequest)object);
		if (monitored_table.containsKey(key)) {
			return monitor.hasChanged(key);
		}
		return false;
	}


Thank you very much.

Dafang Zhang


> -----Original Message-----
> From: Donald Ball [mailto:balld@webslingerZ.com]
> Sent: Wednesday, August 09, 2000 8:23 PM
> To: cocoon-users@xml.apache.org
> Subject: cache madness
>
>
> 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:copy>
>   <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
>   <xsp:logic>
>     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;
>       }
>     }
>   </xsp:logic>
>  </xsl:copy>
> </xsl:template>
>
> (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
> automatically.
>
> - donald
>
>
> ---------------------------------------------------------------------
> 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