After save empty cache of referenced node I have two content types. For clearer question I will work with the content types event and location.

From my location content type I can reference to and event.

Then on the event page I show the location that is connected to this event. I do this by creating a Views Block. This views block is showing content of the type location with a contextual filter to only show content with the Content ID from url.

This works fine. But there are events that don't have a location. On these events page I have a button saying add location. I do this with the following Twig Tweak:

{% if drupal_view_result('view-name', 'location-block') is empty %}
    &lt;a href="/node/add/location"&gt;Add location&lt;/a&gt;
{% else %}
    {{ drupal_view('view-name', 'location-block') }}
{% endif %}


This also works. But when I am on a event page and click the add location button I can add the location. When I go back to the same event page I was before I still see the add location button. Because the page is cached.

Is there a way to empty the cache of this event page after saving the location that is refering to the event? Or is there a other way to deal with this?

I tried if the problem was in the views cache but it wasn't turning it off for the block or removing only the views cache didn't work.

Thanks in advance
You may specify any cache meta data directly in your Twig template. I suppose 'node_list' cache tag can help in this case.

{{ {'#cache': {'tags': ['node_list']}} }}


Another approach could be configuring views 'No results behavior' to show that link.