@Dan, Philip, and Brendan: I think I have a beta version of CE Cache that should play better with EE 2.8.x. Please email me at software at causingeffect.com if you would be willing to try it out.
@Brendan: Keep in mind that CE Cache caches the output from a part of a template. If the the layout tags are within the CE Cache tag, then once the page is cached, the Cache It tag will simply return what was output when it was first run (which is nothing).
For example, let’s say I have a page template, and a layout template:
Page Template:
{layout="layouts/_master" title="The Homepage"}
{layout:set name="contents"} <p>This is the page's content.</p> {/layout:set}
Layout Template:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>{layout:title}</title> </head> <body> {layout:contents} </body> </html>
This part of the “page template” doesn’t actually output anything:
{layout:set name="contents"} <p>This is the page's content.</p> {/layout:set}
So if we cached that chunk of code
{exp:ce_cache:it} {layout:set name="contents"} <p>This is the page's content.</p> {/layout:set} {/exp:ce_cache:it}
, the cached data would actually be an empty string (”“).
Once cached, the Cache It tag would literally replace this:
{exp:ce_cache:it} {layout:set name="contents"} <p>This is the page's content.</p> {/layout:set} {/exp:ce_cache:it}
with nothing (an empty string “”).
Which means that the layout variables would never be set.
Just be sure to always cache both the code that sets a variable *and* the code that gets the variable into the same cache item, or don’t cache either of them. If you cache one or the other, then nothing will ever be output. However, there is no problem with caching the code that goes inside of the setter:
{layout:set name="contents"} {exp:ce_cache:it id="contents"} <p>This is the page's content.</p> {/exp:ce_cache:it} {/layout:set}
I recommend using the same layout approach, but using CE Vars or Stash to set the variables and handle the layout instead. The fact that the {embed} for the template layout can be used inside of the CE Cache tags makes the page a lot more flexible and efficient, because the entire page can be cached while escaping pieces of the page from being cached (any embeds are completely flattened out once cached anyway). There is no way to wrap the entire “page template” tag with the Cache It tag, since the {layout=...} code always has to be on the very first line.
|