Skip to content
Home » How to Fix Sitecore SXA Optimized Assets with an Empty Timestamp

How to Fix Sitecore SXA Optimized Assets with an Empty Timestamp

How to Fix Sitecore SXA Optimized, The Asset module inside the Experience Accelerator is used to optimize CSS styles and JS scripts.

How to Fix Sitecore SXA Optimized, The Asset Optimizer module incorporated inside the Sitecore Experience Accelerator is used to optimize CSS styles and JS scripts. 온라인카지노

If you wish to increase the performance of your site, enable this module in your production environment

Which will reduce the amount of data that must be transmitted.

You have two options for enabling Asset Optimizer as a Sitecore administrator:

Enabling Sitecore on a global scale for the entire instance

Localization for specific areas

To avoid a cache issue when a new delivery happens, both CSS styles and JS scripts are loaded on the client side with a version prefix.

And SXA is no exception: it adds a timestamp to the optimized assets, as illustrated below:

Script src=”/sitecore/shell/-/media/Base-Themes/SearchTheme/Scripts/optimized-min.js?” t=20160908T094830Z”>


We discovered the following issue in one of the projects I worked on: the timestamp was not created for localized sites.

As illustrated below, all optimized assets had an empty timestamp parameter:

Script src=”/sitecore/shell/-/media/Base-Themes/SearchTheme/Scripts/optimized-min.js?”


Because the t argument is a versioning element, this results in the client browser not updating the cached version of CSS styles and JS scripts after another deployment.

So, let’s look into this.


The first step is to determine how and where the timestamp is generated.

Starting with the default SXA layout razor page is a terrific idea. SxaLayout.cshtml is the file name.


As we can see, in order to obtain an asset link, it calls the AssetLinksGenerator type’s static GenerateLinks function.

Going deeper, we can locate the GetOptimizedItemLink method, which is in charge of creating asset links. 카지노사이트

It appears as follows:

If an optimized script item is both not null and not empty in the return expression

The BuildAssetPath() extension method is called.

Okay, we’ve found the location where the timestamp is added. It’s intriguing that it comes from the system’s __Updated template field.

What could be the problem with that? Let’s look at this field.

Okay, the __Updated field is part of the Statistics template, which is included in the Standard Sitecore template.

The important point to note here is that this field is not shared. It means that if we have a site with no default localization

Optimized assets should also contain this language version, which is odd – do we really need localized assets (CSS and JS)? I’m not certain.

As a result, we must implement a remedy to resolve this issue for localized sites.

To begin, we must write our own BuildAssetPath extension method (using the same code as above)

With one more line of code inside the if statement:

Item item1 = item.CheckForFallbackVersionIfExists();

If there are no language versions, this extension method (assembly Sitecore.XA.Foundation.SitecoreExtensions.dll, ItemExtensions.cs)

Returns an item in the default language (typically English).

That is exactly what we require for optimal scripts.

Second, we must build a new type (derived from AssetLinksGenerator.cs)

That has the override GetOptimizedItemLink function as well as a new static GenerateLinks method that hides the base one. 카지노 블로그

11 thoughts on “How to Fix Sitecore SXA Optimized Assets with an Empty Timestamp”

  1. You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!

  2. Pingback: madridbet

  3. Pingback: madridbet

Leave a Reply