Tag Manager container file caching


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


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) +
    '-' +

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];
g.src='https://matomo-server/matomo/js/container_xxxxxxxx.js?d='+todayParam(); s.parentNode.insertBefore(g,s);
<!-- 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

1 Like

@LaurentN you can the create a new feature request on the Matomo GitHub repo:

Hi @heurteph-ei

How can I test if the javascript is implemented correctly and the cache refresh is set to one day?
We have implemented the script and in the network tab I see that today’s date is appended. However, under Cache Control it still shows 8 days.

Thank you very much and best regards,

If you want to test your script (and be sure it works well): Press Ctrl + F5, then all your scripts and assets will be refreshed. Or you can either, when the devtool is open, check the Disable cache option (be careful, this is only taken into account during the time the devtool is open)

In firefox (FR version sorry)

InChrome / Edge

The solution I provided previously allows the script path to change automatically every day, then browsers have to request the script at least once a day…

1 Like

Hi Matomo Support Team,

I created a custom tag in matomo, and it worked. later I modified the same tag and published it.

But still, new changes are not reflected and old tag features are only reflected.

How long does it take to clear cache for paid matomo cloud server ?

Hi @bshankarpandey
As this concern the paid Matomo Cloud, You can reach Matomo team at:
shop at matomo dot org