Hi, one of my simple implementation, hope it helps.
public abstract class StaticCacheComponent { private final static int CACHE_EXPIRED = 60; @Inject private ComponentResources componentResources; @Inject private CacheService cacheService; @Inject private TypeCoercer typeCoercer; private Element fakeElement = null; private String cacheId = null; final boolean beginRender(MarkupWriter writer) { InternalComponentResourcesImpl resourcesImpl = (InternalComponentResourcesImpl)componentResources; StringBuilder builder = new StringBuilder(this.getClass().getSimpleName()); for (String parameterName : resourcesImpl.getComponentModel().getParameterNames()) { boolean isBound = resourcesImpl.isBound(parameterName); String parameterValueStr = null; if (isBound) { parameterValueStr = typeCoercer.coerce(resourcesImpl.getBinding(parameterName).get(), String.class); } builder.append(parameterName).append("_").append(parameterValueStr).append("_"); } cacheId = builder.toString(); String staticCache = cacheService.getCache(cacheId, getCacheExpired()); if (staticCache != null) { writer.writeRaw(staticCache); return false; } else { fakeElement = writer.element("span"); return true; } } final void afterRenderTemplate(MarkupWriter writer) { writer.end(); // must call before removing String innerHTMl = fakeElement.getChildMarkup(); fakeElement.remove(); writer.writeRaw(innerHTMl); cacheService.saveCache(cacheId, getCacheExpired(), innerHTMl); } protected int getCacheExpired() { return CACHE_EXPIRED; } } 2012/7/28 Jens Breitenstein <mailingl...@j-b-s.de> > Hi T5'ers > > we have some performance issues and started thinking about caching our > pages (lets say parts of them to be precise). Due to the fact we are > showing user related information along with "public information" on a page, > we can not make use of a simple web proxy caching. > > Therefore we are thinking about a "component rendering result cache". > > Assume we have several independent components to show an overview of items > (and we have a lot of items rendered in a loop) and we want to cache the > rendering result of one of these particular components for several seconds > before rendering it again (to reflect new items or changes). I am aware > this means we are showing stale data for some seconds, but honestly this is > not an issue because after rendering and displaying it in the browser data > is considerably old anyway :-) > > What might be a good place to intercept the rendering and store the output > from a component and on the other hand use outputraw for sending cached > data? > Does anyone tried this before? > > Any idea or comment is appreciated, thanks in advance > > > Jens > > > > > ------------------------------**------------------------------**--------- > To unsubscribe, e-mail: > users-unsubscribe@tapestry.**apache.org<users-unsubscr...@tapestry.apache.org> > For additional commands, e-mail: users-h...@tapestry.apache.org > >