0

I'm trying to cache some templates using ce_cache and Stash. I can't get this to work, at the moment it's outputting nothing. My simplified 'model' code is something along the lines of:

{stash:embed:layouts:default stash:cache_tags="true"}

{exp:channel:entries status="not closed" disable="categories|category_fields|member_data|pagination|trackbacks"}
    {exp:stash:set name="content_full"}
       <h1>{title}</h1>
    {/exp:stash:set}
{/exp:channel:entries}

And the embed/view:

{if exp:stash:cache_tags}
 {exp:ce_cache:it tags="default"}
{/if} 
{lv_head}
<body id="" class="">
    <div id="wrapper-main">
        {if {exp:stash:not_empty name="content_full"}}
            {exp:stash:content_full}
        {/if}
  </div>    
{lv_footer}
{if exp:stash:cache_tags}
 {/exp:ce_cache:it}
{/if} 
1

I can't see how caching the layout is going to help you at all. It's just markup. You need to "cache" the tags that actually generate content and are expensive to run (i.e. the channel entries tag), as well as the rendering of the data (the layout). Therefore you need to wrap the {exp:ce_cache:it} tags around everything in the root template.

Also this..

{if exp:stash:cache_tags}

..is not a valid conditional.

Your stash embed variable can be used in the form {stash:cache_tag} and must be evaluated as a string, thus:

{if "{stash:cache_tags}" == "true"}

More on evaluating stash variables, and the difference between native and snippet variables here: https://github.com/croxton/Stash/wiki/Variables#ifelse-advanced-conditionals

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.