When {% cache %} in conjunction with {% include ... %} is it better to wrap the Cache outside of the include or put inside of the included file?

{% cache %}
    {% include %}
{% endcache %}


{% include "..." %} 

with the cache directives inside the include file?

Assume for this question that the entire contents of the include file will be cached (complex nav).

1 Answer 1


It doesn't really matter where you have the tags. Yes, you do save the overhead of the include by wrapping the tag, but the impact is minimal (not really measurable) and once compiled to PHP it's cached anyways.

I usually have the cache tags within my partials. It's more flexible, you can cache blocks of code separately and leave out certain parts. I also often use the globally flag and include a partial into multiple templates. Defining the cache tag within the partial makes sure I always use the right cache ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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