

Django tip: Caching and two-phased template rendering - mace
http://www.holovaty.com/writing/django-two-phased-rendering/

======
gfodor
We do something like this -- we call it "partial currying" .. if you think of
a partial (in Rails) as a function of a number of parameters, you can render
and cache the intermediate rendering of a subset of those parameters (curry
them.) Subsequent calls can then specify the values for the rest.

The mechanism we use for this is to do some ruby metaprogramming to kludge in
some placeholder values for the uncurried values, and then gsub them in in the
subsequent passes. (So, the first pass is the only pass that runs the HAML/ERB
file, the rest are gsub's) This works for us, since things after the first
pass are not changing layout, etc, and need to be high performance. The first
pass is a heavyweight rendering at a coarse granularity (and cached),
subsequent curries are lightweight gsubs at fine grain.

------
FiReaNG3L
Is it possible to do the same thing in PHP? Authenticated users performance is
one of the areas Drupal could be improved, and this looks like it could help a
lot.

~~~
mseebach
The quick-and-dirty way is to do it like Smarty does: compile what you want to
cache and write that as a .php file that includes the user-dependent data to
disk.

But, if I'm not mistaken, Drupal with users is slow because pretty much any
function in the system is allowed to change its output depending on the logged
in user, right? And that's pretty tricky to cache.

------
gojomo
While I've not used it yet myself, 'edge-side includes' seem really
appropriate for such problems -- offloading the caching of the large,
unchanging part to a very efficient raw HTTP cache, only passing through
customization hits for a tiny subset of the page (and even allowing those to
be cached and invalidated separately). See:

<http://en.wikipedia.org/wiki/Edge_Side_Includes>

------
jdbeast00
caching in asp.net web controls is insanely easy. ironic that in mvc land
(asp.net mvc included) it is so difficult.

