[Twisted-web] Nevow PageCache

Andrea Arcangeli andrea at cpushare.com
Fri Jan 6 08:08:09 MST 2006

On Wed, Dec 14, 2005 at 02:47:12AM +0100, Andrea Arcangeli wrote:
> On Wed, Dec 14, 2005 at 12:48:00AM +0100, Valentino Volonghi wrote:
> > The right strategy would be to write something similar for twisted.web2 using
> > filters maybe. This would make the implementation significantly easier to
> > maintain and probably shorter.
> So, we should defer it to the time nevow will switch over web2? 
> > Nevow would be the place of fragment caches (for which there is an already
> > implemented API as you may recall).
> Yep, at some point I started using it but then it complicated things too
> much and I removed them. The benefit wasn't big enough. Those caches
> require explicit coding, while the PageCache is instead totally
> transparent and it only requires a two liner patch to be enabled and the
> patched code runs backwards compatible if run on a pristine nevow tree.
> So to me the PageCache is more important and it does 99% of the work.

Can we focus on the API of the app? That's the most important thing
after all, it's the only one that must not change.

My current API is this:

class forever_cached_page_class(rend.Page):
	cache = True
class cached_page_class(forever_cached_page_class):
	lifetime = LIFETIME

class cached_page_class(rend.Page):
	cache = True
	lifetime = LIFETIME
	max_cache_size = 20*1024*1024

(LIFETIME in seconds)

If this API is good, then I suggest adding my patch now even if it's not
the long term implementation, and then once nevow will switch over to
web2, it'll transparently support the same API with web2 support instead
of the PageCache inside nevow.

The PageCache class is absolutely invisible to the web application code
and as such it doesn't need to be a long term implementation.

The only thing we have to focus before including that code, is the API
provided to the nevow application.

Perhaps lifetime should be renamed to cache_lifetime or do you have
other suggestions?


More information about the Twisted-web mailing list