Documentation index

Cookie solution ›

Cache and optimisation of the iubenda cookie solution


If you would like to use a specific version of the iubenda cookie solution, you simply need to insert the following link in lieu of the one normally used in the Cookie Solution: https://cdn.iubenda.com/cookie_solution/versions/0.11.36.4/iubenda_cs.js.

The “0.11.36.4” value must be substituted with the number of the version to be used. Available versions are found in the Current and Stable channels , starting with version 0.11.36.4 (consult the complete changelog for a listing of all released Cookie Solution versions).

Unlike the default link, the link mentioned above has a very extended cache configuration as it points to a specific version which does not require future modifications.

By applying the modification described above to the Cookie Solution, the iubenda_cs.js resource will load a new file containing the desired version. It’s a best practice, also adopted by Google for the loading of Google Analytics, as a way to achieve a compromise between the need to update the Cookie Solution and the loading/cacheing speed. The iubenda_cs.js file is in fact a file with a brief cache of few bytes, which in turn calls the real Cookie Solution, whose cache is much more extensive.

Alternatively, you can bypass iubenda_cs.js and directly load the file with the hash of the version and you will be able to:

  • Eliminate an intermediary passage (resulting however in an almost negligible gain of a few milliseconds)
  • Access a version of the file with a very long cache

Direct loading of the Cookie Solution

If Google PageSpeed provided you with a suggestion similar to the following, we can help you solve the problem:

Look through the browser’s cache: If there is a maximum age for statistic resources in the HTTP headers or if an expiry date is set, the browser will load the the resources previously downloaded from the local disk instead of from the network.

To bypass iubenda _cs.js, the first thing to do is get the hash from the desired version:

  • As we saw before, you need to substitute “0.11.36.4” with the version of the Cookie Solution you wish to activate and visit https://cdn.iubenda.com/cookie_solution/versions/0.11.36.4/iubenda_cs.js. Nota: If you wish to activate the last available option, head directly to the following address: https://cdn.iubenda.com/cookie_solution/iubenda_cs.js
  • Copy the content of the parameter **e**=’XyZ**’**, which is in fact the version’s hash. For example, if we take version “0.11.36.4” visiting https://cdn.iubenda.com/cookie_solution/versions/0.11.36.4/iubenda_cs.js avremo e=”12c7b88758469646a58cf26a33ae0d27″; you will have to copy the following content: 12c7b88758469646a58cf26a33ae0d27

At this point you can compile the new URL with the hash of the chosen version. To do so, simply substitute the link above with the one normally called in the Cookie Solution code. To create the URL, you can use the following structure:

https://cdn.iubenda.com/cookie_solution/iubenda_cs/core-

+

parametre value "e"

Using the last version’s hash for example, the result is the following:

https://cdn.iubenda.com/cookie_solution/iubenda_cs/core-12c7b88758469646a58cf26a33ae0d27

Please note: if you decide to block the iubenda Cookie Solution at a specific version, we suggest that you manually update it so that you may continue to benefit from our updates.

Direct embedding in the page of the activator

The inclusion of the activator inside the page can only be done in the safemode version of our Cookie Solution. For an introduction to safemode, please see the following.

It’s possible to include the part of the code relative to the scripts, directly in-page (inline); this code is known as the inline activator. Scripts can be activated through the inline activator even if the iubenda_cs.js primary resource is generically unavailable or in error.

Additional information

The inline activator only guaranties script activation but can also take on a provided permission (see the following forceSafeActivation option); it cannot be used to show the banner, the cookie policy or manage the obtaining of consent. It serves only as another layer of protection in case of errors and does not at all act as a substitute for the main iubenda Cookie Solution code (for additional information on how to set up the Cookie Solution, you can read this article). Note that the inline activator will only invoke the onActivationDone, while others will be ignored.

Two additional configuration options are available for the inline activator:

safeTimeout: (milliseconds, default 5000)– the time required for the inline activator to be triggered (before activating the script the following option will also present itself

forceSafeActivation: (boolean, default false) – – If true, scripts are activated regardless of consent obtained. If false, the inline activator activates the scripts only if consent has been provided ( and registered in the preference cookie in the page of the host domain)

The inline activation is available at the following URL:

The content of this file is to be included in-page AFTER the initial configurations AND before the code that loads iubenda_cs.js..

Example

<head>
...

<script type="text/javascript">
    var _iub = _iub || [];
  _iub.csConfiguration = {
    cookiePolicyId: XxX,
    siteId: YyY,
    // other config options...
  };
_iub.csConfiguration.safeTimeout = 2000; // Custom option for Safemode
_iub.csConfiguration.forceSafeActivation = false; // Custom option for Safemode
</script>

<script type="text/javascript">
//<![CDATA[
  //copy content from cdn.iubenda.com/cookie_solution/safemode/safe.js and paste here.
//]]>
</script>

<script type="text/javascript" src="//cdn.iubenda.com/cookie_solution/safemode/iubenda_cs.js" charset="UTF-8" async></script>

...
</head>

Example:

The activator code is an integral part of the iubenda Cookie Solution and as such can be modified to include new features, upgrades and fixes. Releases of new versions of the iuenda Cookie Solution that also include the modification of the inline activator are marked in changelog with the [safe.js updated]. To facilitate the management of the activator version in your page, the _iub.csSafeActivatorVersion variable is available, which recalls the iubenda_cs.js version from which the activator was extracted.


Still have questions?

Visit our support forum Email us