Invalidate cache from two channel expiry dates I have two channels: A event and a news channel which I want the cache to expire based on both their expiry Date.

{% set newsDate = craft.entries.section('newsDate').order('expiryDate asc').first() %}
{% set eventDate = craft.entries.section('event').order('konzertStartdate asc').first() %}
{% set currentTime = now |date('c') %}

{% if currentTime &lt;= newsDate %}
    {% set invalidate = newsDate.expiryDate | date('c') %}
{% else %}
    {% set invalidate = auffuehrung.konzertStartdate |date('c') %}
{% endif %}

{% cache unless invalidate %}
 {# blablabla #}
{% endcache %}


As you can see I create two variables and then check which one is newer. But its not working properly.

The news never seem to invalidate the cache.

Do you know a better way to do this?
the error was with the date format in the date comparison conditional and the until tag instead of unless

{% if currentTime &lt;= newsDate | date('c') %} {# those two dates were formated differentely #}
    {% set invalidate = newsDate.expiryDate | date('c') %}
{% else %}
    {% set invalidate = auffuehrung.konzertStartdate |date('c') %}
{% endif %}

{% cache until invalidate %} {# not unless #}
 {# blablabla #}
{% endcache %}