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 %}
Installation Instructions

To install this plugin, copy the command above to your terminal.

Active Installs
1,687
Version
3.0.0
License
MIT
Compatibility
Craft 3, Craft 4
Last release
May 5, 2022
Categories
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
0
Open PRs