Set Cache TTL for Sitecore CDP/Personalize CloudFront JavaScript libraries for faster website performance

Website performance is one of the key measures or KPI that organizations look for when they build any intranet or public facing websites. It is estimated that every second that a website takes longer to load loses 10% of its visitors.

The slowness of a website not only comes from its own resources like css, server-side code, html, images but also the 3rd party client-side JavaScript libraries. In fact, most of the website performance slowness is attributed to these 3rd party libraries.

The problem only amplifies with Composable SaaS products like CDP and Personalize.

In one of the client projects that I was working on earlier this year, the client had specific performance that "all webpages should get a score of 90 and above in the Lighthouse report".

If you don't know what Lighthouse is - read this page to learn about it.

Google Lighthouse is a very popular website performance test that has browser extensions available to test your website from the comfort of your browser.

If you try to hook your website with Sitecore CDP/Personalize, it loads 2 javascript libraries:

  1. boxever-<version>.min.js (ex: boxever-1.4.9.min.js)
  2. version.min.js
For some reason, Sitecore did not set any cache TTL for these libraries.

This apparently had an impact on the Lighthouse performance score across our website.

I created 2 Sitecore support tickets (CS0341367, CS0359239) to set cache TTL for 365 days (1 year) for boxever-<version>.min.js JavaScript since version.min.js is associated with a specific version and therefore not good to set any cache TTL.

Though Sitecore set the cache TTL for 365 days, but the issue still persisted with the Lighthouse.

If you own both CDP and Personalize license, the libraries are loaded from Amazon CloudFront CDN. In order to completely remediate this issue, Lighthouse requires explicit setting of cache-control header in the response.

cache-control: public, max-age=31536000 response header must be added to all CDPJavaScript libraries loaded via CloudFront



Sitecore registered a feature request to add explicit cache-control response headers for CDP/Personalize CloudFront JavaScript libraries.

Hope you find the information in this article useful.

Comments