cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 cache control issue

former_member226851
Participant
0 Kudos

Hallo Everyone,

I have an issue with the cache. When you first run the application it downloads files from a server to the cache, for example 'trc.css' file:

During each next opening of the application it retrieves these files from the cache, instead of checking whether or not they have been changed and retrieve them (when it's needed) from the server.

I have noticed that, for example, if I load the same file using <link href="css/trc.css" type="text/css" rel="stylesheet" />,  a mechanism 304 not modified runs well (when nothing has been changed I get 304 response):

...but when I use jQuery.sap.includeStyleSheet (or in general jQuery.sap.require) it gets this file all the time from cache ('200 from the cache' response), despite any changes in the file, and for this reason many times the file is being downloaded as a outdated, and I have to remember to clear the cache...

Is there any possibility to force 304 mechanism (or any similar, which would control the cache) running using sapui5?

Best regards,

Tomasz Sobkowiak

Accepted Solutions (1)

Accepted Solutions (1)

jmoors
Active Contributor
0 Kudos

Have you had a look at the cache buster and application cache buster?

Cache buster

https://sapui5.hana.ondemand.com/sdk/#docs/guide/91f080966f4d1014b6dd926db0e91070.html

Application cache buster

https://sapui5.hana.ondemand.com/sdk/#docs/guide/ff7aceda0bd24039beb9bca8e882825d.html

Many thanks,

Jason

former_member226851
Participant
0 Kudos

Hi Jason,

Yes, of course I have, unfortunately when I tried to use appCacheBuster it generated an index file with my app files and timestamps, but after I changed a file on SAP it didn't notice that and used the old file from cache.. I'd like to cache those files, nevertheless if some of them have been changed the most recent version have to be downloaded from the server - not used from cache.

Best regards,

Tomasz Sobkowiak

jmoors
Active Contributor
0 Kudos

Strange, the application cache buster should pick up the change and create a new url including the new timestamp, therefore it should been seen as a different resource and therefore the won't be a cached version.

Perhaps it's down to the version you are using, I know the mechanism has been enhanced to include jQuery.sap.includeScript, jQuery.sap.includeStyleSheet, and properties of the type sap.ui.core/URI.

https://sapui5.hana.ondemand.com/sdk/#docs/guide/94e0c33e22474538a65f5f5b4920cdaf.html

Regards,

Jason

former_member226851
Participant
0 Kudos

I've checked and you are right, appcachebuster doesn't get files from cache, however the thing is that when I turned it on (data-sap-ui-appCacheBuster="./"), change a file on SAP and run the app I get the following error for each changed file:

Uncaught Error: found in negative cache: '<changed_file_name>' from ./<localization>: 500 - REQUESTED RESOURCE OUTDATED

...and then my app crashes.

btw. I use 1.22.4 version of sapui5.

Best Regards,

Tomasz Sobkowiak

jmoors
Active Contributor
0 Kudos

Are you running on a Java or Abap stack? It's not an error I've come across, are all your components up to date?

Regards,

Jason

former_member226851
Participant
0 Kudos

The application runs on the ABAP stack. The following issue has been described in the 1832992 sapnote (SAPUI5 Cache Buster for Applications - http status code 500), and it says that the application resource has been requested with the invalid ETag in the URL, but this note cannot be implemented by snote, because I already use SAP_UI 740 0009 version.

Best Regards,

Tomasz Sobkowiak

former_member226851
Participant
0 Kudos

Another hint - I've found the following comment within IF_HTTP_EXTENSION~HANDLE_REQUEST class:

*   An exception 500/'REQUESTED RESOURCE OUTDATED' is returned if a JavaScript resource

*   has been requested in an outdated or invalid version. Requests for other resources

*   are accepted and served with the latest version.

*   The latter case may happen in case a CSS loads images using a relative path:

*   Then the proper etag is not injected in the URL as the UI5 core does not get control.


This is wird, but when I turned the appCacheBuster off and turned it on again and I didn't get any errors... Nonetheless, I'm not sure if it works properly,  because at the first open of the app it generates a index file with a 200 response, then each next time I get a 304 response for this file, so it seems that is's ok, but.. When I change a file in Eclipse, submit changes to SAP, and reboot the application I still get a 304 response for the index file and the file modified by me has an old version before submit.


Are those changes are refreshed every certain period of time?


Best Regards,

Tomasz Sobkowiak


jmoors
Active Contributor
0 Kudos

Do you using <link> or jQuery.sap.includeStyleSheet to include the CSS?

I also came across the following, not sure if resetting the cache buster makes any difference?

Regards,

Jason

Testing the SAPUI5 Application on an ABAP Server - User Interface Add-On for SAP NetWeaver - SAP Lib...

  • As of UI AddOn 1.0 SP03 it may be necessary after system- and language imports for a SAPUI5 application into the SAP NetWeaver Web AS to reset its internal cache buster information. You may explicitly use or schedule the ABAP report /UI5/RESET_CACHEBUSTER to do so on all servers. As an alternative you can trigger the reset for a specific SAPUI5 application from the browser using the URL "<application base path>/resetcachebuster".
former_member226851
Participant
0 Kudos

Yes, I use jQuery.sap.includeStyleSheet as well as <link> to include CSS. When I turned on the cache buster together with appCacheBuster I got the following errors:

I've executed the above report, and it works only with errors related with the appCacheBuster, with the cacheBuster it does not and they still occurs. I've found inside the /UI5/CL_UI5_APP_HTTP_HANDLER class, IF_HTTP_EXTENSION~HANDLE_REQUEST method, that the errors occurs only when wrong ETag has been passed for Javascript files (ETags for CSS and Images are acceptable).

Why those ETags are wrong? How can I fix that?

Best regards,

Tomasz Sobkowiak

0 Kudos

many thanks!  for /UI5/RESET_CACHEBUSTER

Former Member
0 Kudos

Hi Tomasz Sobkowiak,

Did you ever resolved below issue while your application is on AppCacheBuster?

500 - REQUESTED RESOURCE OUTDATED

Thanks,

MS

former_member226851
Participant
0 Kudos

Hi Naga Devisetty,

this error occurs each time I commit new code changes of a sapui5 application on ABAP Repository. So I use SE38 and I execute two reports: /ui5/reset_cachebuster and then /ui5/update_cachebuster. Sometimes they have to be executed more then once. Once they are executed and a web browser is rebooted everything should work fine.

Best Regards,

Tomasz Sobkowiak

Former Member
0 Kudos

Thanks for your reply Tomasz.

But ya, those 2 reports were scheduled in my system and I still had that error (500 Error). And this was actually resolved with some 'project folder hierarchy' changes.. and wasn't real issue with either of the reports.

And /ui5/update_cachebuster does works better than /ui5/reset_cachebuster in my case.

Thanks,

MS

Answers (1)

Answers (1)

former_member226851
Participant
0 Kudos

Moreover, I have just noticed that inside sap.ui.core there is an implementation of jQuery.sap.require which just uses jQuery.ajax to download files. The thing is that 'ifModified' parameter is by default set to 'false', so this is the reason why 304 mechanism doesn't work....

Now the question is what could I do to fix it?

Best Regards,

Tomasz Sobkowiak