Skip to content Skip to sidebar Skip to footer

How To Make The Counter Twig Ignore The Drupal Cache?

This question is related to my previous question : How to create a counter with TWIG? I have a site with Drupal 8 and a menu which includes a task counter : enter image description

Solution 1:

There are mostly 2 solutions to workaround the http cache and still keep the page cache in Symfony.

First one is you load the data which should not be cached over an ajax request.

The simplest way doing this is using hinclude:

https://symfony.com/doc/current/templating/hinclude.html

Else you can use ESI which will do a sub request for the uncached content:

https://symfony.com/doc/current/http_cache/esi.html

For both you need to create a new controller which will load the data you want to be rendered.

Post a Comment for "How To Make The Counter Twig Ignore The Drupal Cache?"