[Twisted-web] html cache with timeout
Valentino Volonghi aka Dialtone
dialtone at divmod.com
Wed Feb 2 00:56:14 MST 2005
On Wed, 2 Feb 2005 03:48:40 +0100, Andrea Arcangeli <andrea at cpushare.com> wrote:
> Is that a separate task? One of the benefits of having cache inside the
> python VM that runs the webserver is no context switches and no inter
> process communication. So I'm not very excited about caching outside
> nevow ;)
The benefits are that it scales to multiple computers, which means a better way to distribute the load. But, as I said, it's just one of the possible backends.
> Ok, so it's up to me to avoid collisions, it's not like the more
> lowlevel cache where the url was picked automatically.
In weever I did a test, and I simply put this in the base class where I fill the content slot (each page is a main page which contains a content slot that is filled with the content Fragment):
t.cached(name=str(self.__class__)+IA(ctx).get('uid', ''), lifetime=10)[...]
Doing this in the main baseclass gave me caching on ALL pages with a per/user cache.
Anyway this is just an implementation problem. Nobody stops you from doing:
def myHttpCache(ctx, lifetime):
return t.cached(name=str(url.URL.fromContext(ctx)), lifetime=lifetime)
Which will give you the same result.
> All my pages are using xml (except for the forms that come from
> formless), so I'd need the cache for xml templates too.
> But I really liked the caching using URL, I don't want having to write
> name="something" by hand.
When I say that it won't work with xml templates I mean that you need a way to create a cached tag from the xml. This is all.
More information about the Twisted-web