I am using a conditional display logic in Bricks to display a message in the header of a site ONLY if the date is before a certain date. The logic appears to work correctly BUT due to caching (I am using OLS and Cloudflare) the message remains on the site.
It seems like the conditional code should be included even in the cached version but that doesnât seem to be the case.
As soon as I clear the cache, the logic works correctly.
here my version with an attribute attached to one block or element. this bypasses the cached version of a page and updates.
Name the element CSS-ID (i.e. mein-text)
Add an attribute to the element (i.e. data-ablaufdatum)
copy this script in settings>custom code> footer scripts
dont forget the opening â<â in sript tag below (snippet does not show here with correct syntax)
test functionality by change the date to the past. 2025-10-01
script>
document.addEventListener(âDOMContentLoadedâ, function() {
const element = document.getElementById(âmein-textâ);
if(!element) return;
const aktuellesDatum = new Date();
const ablaufDatum = new Date(element.getAttribute(âdata-ablaufdatumâ));
if (aktuellesDatum > ablaufDatum) {
element.style.display = ânoneâ;
}
});