[Templates] Caching Output of Components

Todd Freeman freeman@andrews.edu
Sun, 6 Aug 2006 21:59:38 -0400


--pWyiEgJYm5f9v55/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Another option is replace your direct DB calls with something that creates =
a ready-to-go presentation and keeps it cached in Cache::MemCached  or such.

We do this for "events" pages on our pages and have found it to cut process=
ing time by several orders of magnitude.

If you have LOAD_PERL on your can use it directly from your template... or =
you can have a mod_perl handler do the lifting for you.

On Sun, Aug 06, 2006 at 09:29:02PM -0400, Robert James Kaes wrote:
> On Sun, 06 Aug 2006, Randal L. Schwartz wrote:
> > >>>>> "Robert" =3D=3D Robert James Kaes <rjk@wormbytes.ca> writes:
> >=20
> > Robert> I'd like to say "the output of all components are cached.  If a=
 child
> > Robert> component has changed, invalidate the child cache and its paren=
t's
> > Robert> cache."  It would also be nice to selectively say "this compone=
nt's
> > Robert> output must never be cached."
> >=20
> > I've looked at this a number of times, and never gotten very far.  If I=
 may
> > misquote Perrin, he's said something to the effect that the expense for
> > determining when to blow a cache (and how much to blow) often exceeds t=
he cost
> > of just recomputing the darn thing.  And yes, it's a can of worms.
>=20
> Thank you, you raise a good point that I had not fully considered.  My
> goal is to display a dynamically generated page, but where most of the
> "dynamic" content is actually static for a period amount of time.  (Take
> a news page, for example, where the list of news stories updates once an
> hour.)
>=20
> Having thought about the problem a bit more, I can likely simulate what
> I'm looking for by using a template that INSERTs the "dynamic" content
> that was generated by a cronjob periodically.  This would move the heavy
> DB processing offline relative to the page view.
>=20
> Randal, thank you for your insight!
>=20
> Have a great night.
>     -- Robert
>=20
> --=20
> Robert James Kaes
> WormBytes Consulting and Contracting
> http://www.wormbytes.ca/
>=20
> _______________________________________________
> templates mailing list
> templates@template-toolkit.org
> http://lists.template-toolkit.org/mailman/listinfo/templates

--=20
Todd Freeman  Ext 6103                   .^.    Don't fear the penguins!
Programming Department                   /V\
Andrews University                      // \\    http://www.linux.org/
http://www.andrews.edu/~freeman/       /(   )\   http://www.debian.org/
                                        ^^ ^^

--pWyiEgJYm5f9v55/
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFE1p6Enbl1fXtXLfERAjHtAJ9zjna0zCbfm3UGOzGFR+wy6m7nXQCdGw/w
DTf6JW9lC6cGQCX2LJivFNY=
=WExb
-----END PGP SIGNATURE-----

--pWyiEgJYm5f9v55/--