silverstripe/silverstripe-framework — pull request #2148 by jthomerson (2013-06-25 00:52:32+00:00)
Title: TESTCASE: $Layout in cached block executed even when cached

This is a test case that proves Jonathan Menz' assertion in the silverstripe-dev discussion below. It shows that $Layout is processed (which means all method calls, etc, are processed - causing performance problems) even if it does not need to be since it is only referenced within a <% cached %> block.

The problem with the code lies in SSViewer->process where the Layout and Content templates are executed and made into an underlay before $this->includeGeneratedTemplate is called. They are executed even though they may not be needed. It seems as if they need to be turned into some kind of closure that only gets executed as needed.

See https://groups.google.com/d/msg/silverstripe-dev/itYU50HoH50/aR6grcPIBSYJ