EP-4447419-B1 - SERVICE WORKER CONFIGURED TO SERVE MULTIPLE SINGLE PAGE APPLICATIONS
Inventors
- RAY, ANINDA
- MYREN, DENNIS JOEL DAVID
- Verma, Isha
- LIU, ZHI
- CHEN, ZHENGUANG
- FAN, JOHN D.
Dates
- Publication Date
- 20260513
- Application Date
- 20210323
Claims (13)
- A computer-implemented method for a service worker (108) to serve a plurality of single page applications (116) hosted in a dynamic uniform resource locator, URL, space, comprising: intercepting (502), by the service worker, a request from a browser executing on a user device (102), the request associated with a URL of a web page being displayed via the browser; matching (504) at least a portion of the URL associated with the request with a route path in an entry of a routing table (122); determining (506), from the entry of the routing table, an identification of one of the plurality of single page applications served by the service worker; invoking (508) execution of an application controller (118) associated with the one of the plurality of single page applications to handle the request associated with the URL; the method being characterized by further comprising the steps of: assigning a plurality of client identifications to a plurality of instances of the one of the plurality of single page applications, the plurality of instances executing in the browser; and populating the routing table with the plurality of client identifications to enable messages to be routed, by the service worker, between the plurality of instances of the one of the plurality single page applications executing in the browser and the application controller.
- The computer-implemented method of claim 1, wherein: the application controller (118) is configured to manage life cycle operations for the one of the plurality of single page applications (116); and the life cycle operations comprise one or more of an install operation, an activate operation, a request handling operation, a sync operation, or a message operation.
- The computer-implemented method of claim 1 or 2, wherein the application controller (118) is executed separately from other application controllers associated with other ones of the plurality of single page applications.
- The computer-implemented method of any one of claims 1 through 3, wherein the route path comprises a static route path and the method further comprises: installing the service worker (108) and the application controller (118) prior to intercepting the request; and populating the routing table with the entry that includes the static route path in accordance with a property defined in the application controller upon installation of the service worker and the application controller.
- The computer-implemented method of any one of claims 1 through 3, wherein the route path comprises a dynamic route path configurable to access different ones of the plurality of single page applications (116) in accordance with settings defined by tenants of a cloud-based platform hosting the plurality of single page applications.
- The computer-implemented method of claim 5, further comprising populating the routing table (122) with the entry that includes the dynamic route path based on an intercepted response from a network server when the URL is initially accessed by the browser, wherein a header of the intercepted response maps the dynamic route path to the identification of the one of the plurality of single page applications (116).
- The computer-implemented method of any one of claims 1 through 6, wherein a scope defined for the service worker (108) comprises a root directory for a web site that includes the dynamic URL space.
- The computer-implemented method of any one of claims 1 through 7, wherein the matching of at least the portion of the URL associated with the request with the route path in the entry of the routing table (122) comprises pattern matching of one or more path segments.
- A service worker (108) to serve a plurality of single page applications (116) hosted in a dynamic uniform resource locator, URL, space, comprising: one or more processing units; and computer-readable storage media storing instructions that, when executed by the one or more processing units, cause the device to perform operations comprising: intercepting a request from a browser executing on a user device (102), the request associated with a URL of a web page being displayed via the browser; matching at least a portion of the URL associated with the request with a route path in an entry of a routing table (122); determining, from the entry of the routing table, an identification of one of the plurality of single page applications; and invoking execution of an application controller (118) associated with the one of the plurality of single page applications to handle the request associated with the URL; the service worker being characterized by the operations further comprising the steps of: assigning a plurality of client identifications to a plurality of instances of the one of the plurality of single page applications, the plurality of instances executing in the browser; and populating the routing table with the plurality of client identifications to enable messages to be routed, by the service worker, between the plurality of instances of the one of the plurality single page applications executing in the browser and the application controller.
- The device of claim 9, wherein the route path comprises a static route path and the operations further comprise: installing the application controller (118) prior to intercepting the request; and populating the routing table (122) with the entry that includes the static route path in accordance with a property defined in the application controller upon installation of the application controller.
- The device of claim 9, wherein the route path comprises a dynamic route path configurable to access different ones of the plurality of single page applications (116) in accordance with settings defined by tenants of a cloud-based platform hosting the plurality of single page applications.
- The device of claim 11, wherein the operations further comprise populating the routing table (122) with the entry that includes the dynamic route path based on an intercepted response from a network server when the URL is initially accessed by the browser, wherein a header of the intercepted response maps the dynamic route path to the identification of the one of the plurality of single page applications (116).
- A computer readable storage medium that stores instructions that, when executed by one or more processing units, cause a device to perform operations comprising: intercepting a request from a browser executing on a user device (102), the request associated with a URL of a web page being displayed via the browser; matching at least a portion of the URL associated with the request with a route path in an entry of a routing table (122); determining, from the entry of the routing table, an identification of one of the plurality of single page applications; invoking execution of an application controller (118) associated with the one of the plurality of single page applications to handle the request associated with the URL; the medium being characterized by the operations further comprising the steps of: assigning a plurality of client identifications to a plurality of instances of the one of the plurality of single page applications, the plurality of instances executing in the browser; and populating the routing table with the plurality of client identifications to enable messages to be routed, by the service worker, between the plurality of instances of the one of the plurality single page applications executing in the browser and the application controller.
Description
BACKGROUND A single page application (SPA) is a web application that interacts with a browser to write data to a web page without requiring the loading of an entire web page. Via the use of a single page application, code (e.g., Hyper-Text Markup Language (HTML), JavaScript, Cascading Style Sheets (CSS)) for a web page can be retrieved by the browser via local files stored on a device executing the browser. That is, a user device has the ability to initially download a single page application from a network server and subsequently execute the file(s) from local storage without having to depend on a network connection to a network server (e.g., client-side rendering). A service worker is a programmable network proxy configured between the browser and the network server. The service worker is capable of intercepting requests from the browser and enabling communications with a single page application stored locally on the device. More specifically, a service worker is a script that a browser executes in the background, separate from execution of a web page, which allows a single page application to independently control the handling of network requests for the web page without having a network dependency. Use of a service worker allows the browser, and therefore the user device, to reduce the runtime latency, improve end-user perceived latency, and reduce the network dependency. Traditionally, a service worker is bound to a specific single page application. In other words, a service worker is dedicated to a lone single page application resulting in a conventional one-to-one association between a service worker and a single page application. Accordingly, a user device needs to expend the resources (e.g., memory and compute units) to execute multiple service workers when a browser is rendering web pages for multiple single page applications. In many scenarios, these multiple single page applications are hosted against the same root scope. A root scope may correspond to an online service domain (e.g., 'www.contoso.com') that hosts different single page applications (e.g., 'mail.contoso.com' and 'calendar.contoso.com'). Execution of multiple service workers for multiple single page applications that are hosted against the same root scope results in additional resource use because service workers have to be unregistered and reregistered as a user switches from using one single page application to another. This process of unregistering and reregistering service workers ultimately has a severe impact on the boot time of the single page applications. Furthermore, a traditional service worker is configured to make a deterministic association between a uniform resource locator (URL) of a web page being executed by the browser and a single page application. A traditional service worker is not configured to handle a dynamic URL where there is no deterministic association between a URL and a single page application. A dynamic URL is one that can refer to pages of different single page applications depending on settings defined by a tenant. For instance, one tenant of a cloud service provider may configure a search application to be served from 'www.contoso.com', while another tenant of the cloud service provider may configure a mail application to be served from the same URL - 'www.contoso.com'. Consequently, the one-to-one deterministic approach is not compatible with dynamic URLs because a traditional service worker does not know whether a dynamic URL is deterministically associated with the single page application to which the service worker is dedicated. It is with respect to these and other considerations that the disclosure made herein is presented. US 2017/034306 A1 discloses a software application architecture allowing for creation of a web application that has multiple Single Page Applications (SPAs) within the application. The software application architecture includes components that are common to each page of the web application while also having components that are dynamically loaded to cater to specific respective pages within the application. The dynamically loadable components can be identified based on an identifier in a path being browsed using a web browser application. The described application architecture may be used in the context of AngularJS, as well as other SPA technologies and non-SPA technologies. SUMMARY It is therefore the object of the present invention to provide an improved computer-implemented method for a service worker to serve a plurality of single page applications hosted in a dynamic uniform resource locator (URL) space, a corresponding service worker, and a computer readable storage medium that stores instructions that, when executed, cause a device to perform corresponding operations. This object is solved by the subject matter of the independent claims. Preferred embodiments are defined by the dependent claims. The disclosed techniques provide a service worker that is capable of s