0

Recently we came across an issue where the new changes made in a js file used in the Sitecore Forms were not reflecting.

We fixed it temporarily purging the CDN cache. However, we are looking for a permanent solution.

The files are in sitecore%20modules/Web/ExperienceForms/scripts/maps/src/js/modules/Forms/ Will the versioning work? If yes how can we do a version of those files as we do not have an explicit reference for them?

In my further investigation I noticed the js files for sitecore forms are not referred from the Scripts field. enter image description here

Looks like the below bundling takes care of the js gulp. enter image description here

enter image description here

0

3 Answers 3

0

By default, all the forms related scripts are in sitecore%20modules/Web/ExperienceForms/scripts folder.

They are all referenced on each of the form items on Scripts field, however as content authors do not edit the field, the field value is always coming from Standard Values item of the Form template:

enter image description here

If you want to make sure that new version of the script is loaded, you can just add any query parameter to the changed file reference in that Scripts field on Standard Values item and it will be updated on each page that uses form.


EDIT

From the edit of your question it seems that you have custom bundle mechanism that gathers all the scripts, bundles them and uglifies and then renders custom link to the bundle. If I understand that custom code correctly, there is a chance that it would be enough to include e.g. -v2 suffix in the bundle name to make it 'forms-v2', like:

name: 'forms-v2',
paths: ['node_modules', '.src/js/modules/Forms/'],
....

You may need to update the file which uses the bundle potentially as well, but it's not in here.

Optionally, it may be just enough to update the file which references ...src/js/modules/Forms/ folder to include ?v=... parameter in the link.

Anyway, it's custom implementation and not related to out of the box Sitecore forms javascripts.

1
  • Hi Marek, Thanks for the response. The js references are not done through the Scripts field of the Form. Looks like something is done through the glup.js. Have edited my question with screenshots. Feb 14 at 10:37
0

The best way to fix it is to add a version number or random query string in the script URL. If adding a version number to the scripts for each change is not easy enough, then you can create a task in your pipeline to purge the CDN cache for the forms scripts folder sitecore%20modules/Web/ExperienceForms/scripts every time during the deployment to make sure new that CDN is caching the file with the new changes. Thanks

0

One potential solution could be implementing versioning for the JavaScript files. This would ensure that whenever changes are made to the files, a new version is generated, and the updated version is served to users, bypassing the cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.