[Zope] Idea of Caching DTML Methods in Zope

Tino Wildenhain tino@wildenhain.de
Wed, 23 Oct 2002 20:03:32 +0200


Hi,

--On Mittwoch, 23. Oktober 2002 11:26 +0100 Jaroslav Lukesh 
<lukesh@k-net.cz> wrote:

> Hi all,
....

> For example, two methods:
>
> siteroot
> <dtml-var BASE1>/
>
> localroot
> <dtml-in "PARENTS[3:]">../</dtml-in>
I dont think your example serves very well because the cache
lookup would be comparable to this simple calculation, may
be the cache lookup is even costyer.

....
> So it is possible to do "dynamic" caching? What I mean, is store all
> localroot objects in context of calling direcotry (or another object).

You can define one or more request variables as "key" for different
object versions (RAM Cache manager), so you can use PARENTS here
as well.

> I have few hundreds of calling localroot per page and I will be hapy if it
> will have some solution for that. I dont want migrate to siteroot because
> it makes absolute URLs, not relative.

if localroot is a python script, you could use something like this:

if request.has_key('_mylocalroot'):
    return request.get('_mylocalroot')

localroot=...
request.set('_mylocalroot',localroot)
return localroot


> I know, I could use squid and Accelerated cache manager as reverse cache
> for caching whole pages, but it is not wanted solution (because you cannot
> see immediatelly changes to pages).

Sure you can. Both cache managers support "invalidation" of cached entries
if the object changes. For RAM Cache its normal behavior and for
Accelerated cache manager you have to give the URL to the proxy
for it to work - and the rights for the server where your Zope lives.

> Many thanks for tips or implementation ;-)

Further, you are constructing links like
<someroot>/more/path/elements

Do you think this is useful?
You could either use /path/from/your/root (without servername)

or object_to_link_to.absolute_url()
which gives you the whole string. If you are using
VirtualHostMonster and friends, you dont have to worry about
wrong servernames.

HTH
Tino Wildenhain