1

I was wondering if it makes sense to wrap these {% cache %} around {% include %} tags that call a separate file with params. Is it better to just include them in the actual file itself?

For example, I was using cache tags around includes that call main navigation HTML in the header, like so:

{% cache globally %}
  {% include '_partials/navigation/config.twig' with {
     menuLinks: menuNavLinks,
     direction: "right",
     type: "header" 
   }%}
{% endcache %}

This was causing an allocated memory error that took me forever to debug. FYI I am running locally on XAMPP and my memory_limit is set to 128M; when I increased this, it caused even more issues, related to Database Exception "MySQL error 2006: mysql server has gone away."

Is this not advised and against proper {% cache %} practices?

1

General answer: It is not wrong to put include tags in cache tags.

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.