Cache-bust pages containing embedded content

The saying goes, there are two hard problems in computer science: caching, naming things, and off-by-1 errors. While Drupal certainly has not solved the naming things, it has made a valiant attempt at a decent caching strategy. And for the most part it works great, allowing millions of lines of code to load up quickly the vast majority of the time.

This is more a tip about our favorite automation tool, the Events, Conditions, and Actions (ECA) module, and how it can get you out of a bind when Drupal caching goes too far.

If you have another website or application you want to embed in your Drupal site, especially if there is any kind of personalization or authentication involved, you may need to turn off Drupal's caching for the page you load it on. The ECA Cache module provides an action to change the cache settings of a render array, and combined with the "ECA Entity" event from the cache module, you can set the Max-Age cache header to zero.

For a client site that needed this, we found that was not quite enough -- we also needed to set Drupal's internal page cache kill switch. There wasn't a plugin to handle this just yet, so we created one that may be in ECA Cache shortly -- see https://www.drupal.org/project/eca/issues/3493008 if you need it before it's released.

Advent 2024 -- 24 days of Automations

Add new comment

The content of this field is kept private and will not be shown publicly.

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <blockquote cite> <cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h1> <h2 id> <h3 id> <h4 id> <h5 id> <p> <br> <img src alt height width>
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.