Custom Blocks in Drupal and Issues with Caches

I just ran into a problem on a client's project. The thing is, we have a custom block with two fields, but we only render one of them in Twig, as we have modified the Twig template and do not use the default {{ content }}.

¿Problem?

If the user modifies the other field that is not rendered, then the caches are not invalidated. And the value of that field does other things that do affect the frontend. This is a problem because the user's changes are not displayed.

Solution 1 (Crude)

Tell the user that every time they edit that block, they need to manually clear the caches.

Solution 2

Modify the Twig of that block to force the use of caches for all the content.

If you want to research the topic further: https://www.drupal.org/project/drupal/issues/2660002

If you just want a quick fix, put the following in the block template:

{% set catch_cache = content|render %}

Have Any Project in Mind?

If you want to do something in Drupal maybe you can hire me.

Either for consulting, development or maintenance of Drupal websites.