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.

Reviews

This plugin doesn't have any reviews.

Active Installs
3,184
Version
3.0.4
License
MIT
Compatibility
Craft 3, Craft 4, Craft 5
Last release
September 24, 2024
Categories
Activity (30 days)
0
Closed Issues
0
Open Issues
0
Merged PRs
1
Open PRs