A Craft CMS Twig extension that escapes caching inside cache blocks

{% cache %}
	This will be cached
	{% nocache %}
		This won't be
	{% endnocache %}
{% endcache %}

It also works when disabling the cache from included files:

{% cache %}
	This will be cached
	{% include 'template' %}
{% endcache %}

template.twig:

{% nocache %}
	This won't be
{% endnocache %}

If you need to reference variables outside of the nocache tag, you will need to pass a context – much like how the include tag works when passing variables. Note that you do not have to pass global variables, such as craft or currentUser, but you will have to import your macros again.

{% set variable = 5 %}
{% nocache with {x: variable} %}
	The following value should be 5: {{ x }}
{% endnocache %}

Free

Package Name

To install this plugin, search for its package name on the Plugin Store and click “Install”.


Information

  • Version 2.0.5
  • Last Update 10/8/2019
  • Active Installs 236
  • Compatibility Craft 3
  • License MIT
  • Categories Templating

Report an issue