[Templates] Caching Output of Components

Buddy Burden buddy@thinkgeek.com
Fri, 11 Aug 2006 13:13:20 -0400


Bill,

> One problem I have is that I have a ton of "static" pages -- the
> content is static and the full page is built by TT.  I quote "static"
> because the pages all show either the "login" link, or once logged in, show
> the user's name (and also the menus change a bit).  So, those can't
> really be cached, even for a few seconds -- you can't login in and
> still see a page that says "login".

We have a similar problem here.  Now, we haven't actually tried implementing this yet, because we haven't found the dev 
cycles to devote to it, but here's a plan that we came up with.

We take our templates that have such substitutions and turn them into "two pass" generation templates.  We use two 
different pairs of delimiters to distinguish between variables that can be substituted and then cached, and variables 
which must always be regenerated on every page load.  Then we run it through TT2 once, cache that, then run it through 
TT2 a second time before displaying.

That's just a rough outline, but it's what we came up with.  I present it mainly in the hope that it might spark ideas 
from others (or perhaps that others might have thoughts on how to improve the plan).


		-- Buddy