cancel
Showing results for 
Search instead for 
Did you mean: 

SAP MII UI5 Application Cache Buster not working For JS files

https://answers.sap.com/questions/367944/sap-mii-ui5-application-cache-buster-not-working.html?child...

With reference to the above discussion i have done the cache buster in the MII UI5 application.

  • In that Js files and the controller files and the formatter files are not been applied with the versions by this method
  • The view files, fragment files, json files, manifest file are getting updated with these versions
  • ONLY JS FILES ARE NOT WORKING
  • Because of this what ever the changes that i do in views am getting and the changes that are did in controller are not reflecting because those files do not have the version behind the file names.

Application specs:

  • SAP UI5 version: 1.60
  • Have codes inside SAP MII Workbench.

JSON and xml files which loads with version

network-cahce-buster-2.png

JS files which loads without versioning

index.html

Accepted Solutions (1)

Accepted Solutions (1)

former_member185280
Active Contributor
//$.ajaxSetup({ data: { _TheAppVersion: data._TheAppVersion }});
(function() {
   var proxied = window.XMLHttpRequest.prototype.open;
   window.XMLHttpRequest.prototype.open = function() {
    var url = arguments[1];
    if(url.indexOf("?") == -1){ url = url + "?"; }
    arguments[1] = url + "&_TheAppVersion=" + data._TheAppVersion;
    return proxied.apply(this, [].slice.call(arguments));
   };
})();

Overriding XMLHttpRequest.open() like this seems to work but I don't know if it is a good practice to do this. I suppose with this method if you got into parsing the url you could probably avoid having to reload the ui5 libs when your app version changes wich would be nice.

Regards,
Christian

christian.libich5

This seems to be working fine , since we are just appending the versions to the file names, there is nothing related to good practice i feel. because when we do a clear cache and hard refresh in the browser, it takes much more time than this.

So, i feel this is a better solution and we can use it in any versions irrespective of the loaders that varies from version to version.

I too was thinking of doing similar solution but i wasn't aware from where to pick these files and append the versions. From this i got the answer for that as-well.

Thanks a lot for your quicker and the productive solution that's been provided. 🙂

Answers (1)

Answers (1)

former_member185280
Active Contributor

Bhanu,
I do not have access to check at the moment but I see that you configured ui5 to use the app cache buster and I suspect this might be causing your issue. The cache buster isn't supported on netweaver. I think the cache buster uses its own scope/mechanism for loading resourced and because there is no service on the netweaver side to tell it that the files are updated it doesn't appending anything to the urls to try to get the new versions. In your screenshots you can see how the ones being grabbed with the _AppVer... are grabbed by jquery... and the ones without are grabbed by ui5loader...

Anyway just a guess but give it try without the cache buster configured in the ui5 bootstrap.

Regards,
Christian

christian.libich5

I have tried removing the cache buster as well, but i am facing the same issue. Even when the cache buster is removed the js files are being loaded by the ui5loader and the js files are not being grabbed with the _Appversion. please help here. Thanks in advance

christian.libich5

I found where is the problem, when i use the versions below 1.56 like 1.52, 1.50's the js files are being loaded by jquery in some versions and sap.ui.core in some versions. In those versions the js files are getting grabbed with the _Appversion.

But when i use 1.56 and above the js files is being loaded by ui5loader, where the js files is not getting grabbed with the _Appversion.

In my application am using 1.60, with which the ui5loader works and the issue comes.

Is there any solution that you can suggest for this.

former_member185280
Active Contributor

Looks like at a certain version they changed the way they are loading certain modules, probably as part of removing jQuery dependancies. I don't have a solution at the moment and would recommend putting in a ticket with SAP and see if they have any suggestions. You may want to find an openui5 community and see if they have any solutions. Or try to dig into the ui5 code and see if you can sort it out for all of us 🙂

Regards,
Christian