Skip to Content

Has anyone worked on Service Worker Implementation in SAPUI5 ?

I am trying to improve the performance of the Fiori Apps using SAPUI5 framework by making it a Progressive Web App.

So I was trying to implement a Service Worker which is similar to a web worker and would help in offline browser activity especially mobile apps, and cache all the date on the client side.

The problem I am facing in the request conversion. So what I think is, SAPUI5 uses XHR request which I need to probably convert to FETCH API which Service Worker uses.

If anyone has worked on it, do let me know. I would love to have a discussion.

Regards,

Beni

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Aug 24, 2017 at 08:39 AM

    Update: Check this blog post by Mehmet to see how to reduce sync XHRs

    ___

    Previous answer..:

    No, currently it's not possible to leverage Service Worker because of the heavy usage of sync XHRs in UI5 internally (e.g. requireSync is often used). Service Worker API demands async XHR only as mentioned in MDN:

    "A service worker is run in a worker context: it therefore has no DOM access, and runs on a different thread to the main JavaScript that powers your app, so it is not blocking. It is designed to be fully async; as a consequence, APIs such as synchronous XHR and localStorage can't be used inside a service worker."

    Therefore, we either have to modify UI5 so that it doesn't send any sync XHR, or we have to wait until UI5 gets rid of sync XHRs completely which will be done hopefully at the end of this year.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 12, 2017 at 04:39 PM

    Hi

    Did you make any progress on this topic? I am also interested in using service workers in my SAPUI5 apps

    Kind regards

    Add comment
    10|10000 characters needed characters exceeded