Tag Manager container file caching

Hello,

by default Matomo Tag Manager (cloud) uses 8 days lifetime for cache of current version container files according to https://matomo.org/faq/tag-manager/how-long-will-the-container-javascript-filesbe-cached-for-in-visitors-browsers-js-container_-js-files/.

We are running on paid cloud plan, is there a way to decrease this period significantly or remove caching completely? We are adding Matomo platform to our websites and our sophisticated setup (dataLayer, multiple websites, ecommerce, etc.) requires constant adjustments. We can’t wait 8 days for all changes to reflect as this doesn’t allow us to use Matomo as Google replacement. Our websites have low traffic we are talking about 2000-2500 total non-unique pageviews a day.

I have contacted support, but so far no reply. Can anyone advise?

Thank you, Alex

2 Likes

If you want to reduce the cache to 1 day, you can do something like:

<!-- Matomo Tag Manager -->
<script type="text/javascript">
/**
 * Inspired from Date.prototype.toISOString polyfill https://github.com/behnammodi/polyfill/blob/1a5965edc0e2eaf8e6d87902cc719462e2a889fb/date.polyfill.js
 */
function todayParam() {
  function pad(number) {
    if (number < 10) {
      return '0' + number;
    }
    return number;
  }

  var today = new Date();

  return (
    today.getUTCFullYear() +
    '-' +
    pad(today.getUTCMonth() + 1) +
    '-' +
    pad(today.getUTCDate())
    );
}

var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
var 
g.type='text/javascript';
g.async=true;
g.src='https://matomo-server/matomo/js/container_xxxxxxxx.js?d='+todayParam(); s.parentNode.insertBefore(g,s);
</script>
<!-- End Matomo Tag Manager -->
1 Like

Hey! We are having this exact same issue and will try the workaround to bypass the cache.

Hi all !

Philippe, thank you so much for this tip to force the refresh of the container script.

One suggestion for Matomo Cloud team if I may ; it would certainly be useful to display this information regarding the container script 8 days cache somewhere well visible :wink:

It would certainly spare quite a few troubles for new Matomo Tag Manager adopters !

Best rgds
Laurent