Skip to Content
Author's profile photo Omri Cohen

A primitive application cache buster for SAPUI5 and non GW servers


As we all know SAPUI5 loads our code files on demand (ajax calls).

The files are loaded from cache (if any) which helps performance but can also cause problems if we updated the code files (the user must clear browser cache).

SAP GW has a builtin solution application cache buster:

However, there are cases that we’re not using SAP GW (in my case the SAPUI5 apps are deployed to standard SAP J2EE server) and we want to prevent cache when deploying new app version to production environment.

We need to perform these steps:
1) Create a variable (at window level) with unique value in our index.html

2) Under ‘Web Content’ we need to create folder with the same unique value from step 1

3) use in order to load files from our new path (also in index.html)

We use for all our sub folders which is under folder from step (2)

4) Last but not least: since we don’t want to change the link of our app (it doesn’t make sense) the index file is outside our new folder. so we create a new file: indexNoCache.html which add timestamp as parameter and redirects to index.html (this prevents cache)



<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">

var sViewName = getParameterByName('viewName');
var sTimestamp =;

var sLink = "index.html?viewName=" + sViewName + "&ts=" + sTimestamp;

location.href = sLink;

function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));



The viewName part is there in case we want to start our app from a specific view.
In this case we’ll add the following code to our component.js file ‘init’ function:
UIComponent.prototype.init.apply(this, arguments);

var sViewName ="viewName");
if (sViewName) {
var hashChanger = sap.ui.core.routing.HashChanger.getInstance();


One of the downside of this solution is that when using mimes (images etc) we need to do it on controller level and not on view level because if we’ll use view level we’ll need to hardcoded the value from step (1) which is not good.

In order to solve it we’ll do the following from our controller code (for example setting icon):

var oLogo = this.byId("LogoImg"); ('this' controller or view)
oLogo.setSrc("./" + window.clalitSterileSupplyAppVer + "/images/Logo.png");

5) In order to run the app:

Start from specific view:
http://<server>:<port>/appName/indexNoCache.jsp?viewName=myCusomView (myCustomView was defined in routing section of manifest.json).

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo christian libich
      christian libich

      I ran into the same issue. Linking to the thread where I posted a solution as another option for those dealing with this.