Service worker configured to service multiple single-page applications
By designing a service worker that supports multiple single-page applications and optimizing URL processing using routers and routing tables, the high resource consumption and difficulty in handling dynamic URLs in existing technologies are solved, achieving fast, seamless browser application switching and an optimized user experience.
Patent Information
- Application Number
- CN202180039422.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-07-31
- Filing Date
- 2021-03-23
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2041-03-23
AI Technical Summary
The existing service worker can only be bound to a single single-page application, which requires frequent unregistration and re-registration when switching between multiple single-page applications in the browser, affecting startup time and failing to effectively handle dynamic URLs.
Design a service worker that can serve multiple single-page applications, associating URLs with the correct application controllers through routers and routing tables, supporting both static and dynamic URLs, reducing resource consumption, and optimizing user experience.
It enables seamless switching between multiple single-page applications, reduces resource consumption, improves browser startup speed, and supports flexible handling of dynamic URLs.
Smart Images

Figure CN115668894B_ABST
Abstract
Description
Background Technology
[0001] A Single Page Application (SPA) is a web application that interacts with a browser to write data to a web page without loading the entire web page. By using SPAs, a browser can retrieve the code for a web page (e.g., Hypertext Markup Language (HTML), JavaScript, Cascading Style Sheets (CSS)) from local files stored on the device running the browser. That is, a user device can initially download the SPA from a web server and then execute one or more files from its local storage device, without relying on a network connection to the web server (e.g., client-side rendering).
[0002] A service worker is a programmable network proxy configured between the browser and a web server. A service worker intercepts requests from the browser and enables communication with the single-page application (SPA) stored locally on the device. More specifically, a service worker is a script that runs in the browser background, separate from the execution of the web page. It allows the SPA to independently control the handling of network requests for the web page, without network dependency. The use of service workers allows browsers and thus user devices to reduce runtime latency, improve end-user perceived latency, and reduce network dependency.
[0003] Typically, service workers are bound to a specific single-page application (SPA). In other words, a service worker is dedicated to a single SPA, resulting in a typical one-to-one association between the service worker and the SPA. Therefore, when a browser renders web pages for multiple SPAs, the user's device needs to consume resources (e.g., memory and computing power) to execute multiple service workers. In many scenarios, these multiple SPAs are hosted relative to the same root scope. The root scope may correspond to an online service domain (e.g., 'www.contoso.com') hosting different SPAs (e.g., 'mail.contoso.com' and 'calendar.contoso.com').
[0004] Running multiple service workers for multiple single-page applications hosted relative to the same root scope results in additional resource usage because when a user switches from using one single-page application to another, the service worker must be unregistered and re-registered. This process of unregistering and re-registering service workers ultimately significantly impacts the startup time of the single-page applications.
[0005] Furthermore, regular service workers are configured to establish a deterministic association between the Uniform Resource Locator (URL) of a webpage executed by a browser and the single-page application. Regular service workers are not configured to handle dynamic URLs, where there is no deterministic association between the URL and the single-page application. Dynamic URLs can reference pages of different single-page applications depending on settings defined by the tenant. For example, one tenant of a cloud service provider might configure a search application to serve from 'www.contoso.com', while another tenant of the same cloud service provider might configure an email application to serve from the same URL—'www.contoso.com'. Therefore, the one-to-one deterministic scheme is incompatible with dynamic URLs because regular service workers do not know whether a dynamic URL is deterministically associated with a single-page application specific to the service worker.
[0006] Regarding these and other considerations, the disclosures made herein are presented. Summary of the Invention
[0007] The disclosed technology provides a service worker capable of serving multiple Single Page Applications (SPAs) hosted in the same Uniform Resource Locator (URL) space (e.g., a domain hosting multiple SPAs within it). Therefore, the scope of the service worker is no longer defined by a single SPA, but rather by the root directory of a website (e.g., 'www.contoso.com') hosting multiple SPAs (e.g., a calendar SPA, an email SPA, a search SPA, etc.). By using the technology described herein, when a user switches from using one SPA to using another in their browser (e.g., a user clicks a link in a calendar application to access an email application in the same root directory), the browser no longer needs to unregister and re-register separate service workers, because a common service worker serving both SPAs is already registered and running.
[0008] As described herein, a user's device browser is configured to download and / or install the service worker and multiple single-page applications upon first access to a webpage (e.g., a homepage or welcome page) contained in a root directory that defines the scope for the service worker. The browser is configured to register with the service worker. Each of the multiple single-page applications includes an application controller. By using the application controller, a single-page application is able to define its own offline experience (e.g., a bootstrap sequence) without having to access or receive files and / or instructions from a web server. Instead, as part of the service worker package, the application controller downloads files and enables subsequent access to data storage associated with the single-page application it serves. Providing single-page application developers with the flexibility to control offline scenarios is important because different single-page applications can handle content loading and / or synchronization differently to optimize the user experience. Therefore, although the service worker described herein is configured to serve multiple single-page applications, the service worker enables different experiences to be executed via separate application controllers associated with the single-page applications.
[0009] The application controller is configured to manage the service worker lifecycle and provide various operations based on the lifecycle. For example, by using an application handler, the application controller can cause navigation requests, such as fetching events, to be implemented for a single-page application. In another example, by using an application handler, the application controller can dynamically render dynamic hypertext markup language using streaming responses. In yet another example, by using application configuration, the application controller can provide access to runtime configuration data stored in a local data store. Furthermore, lifecycle operations can include installation operations, activation operations, request handling operations, synchronization operations, messaging operations, etc.
[0010] Since the service worker described herein serves multiple single-page applications, it implements a scheme to ensure that the correct application controller corresponding to the single-page application hosting the URL is invoked. To this end, the service worker is configured to utilize routers and routing tables to associate the URL included in a request from a browser with the correct application controller of the single-page application hosting the webpage that sends the request. As described above, the URL is hosted within a root directory that defines the scope for the service worker.
[0011] In the various examples described herein, the URL can be a dynamic URL, which can be associated with different single-page applications served by the service worker based on user-driven settings defined in the tenant account. Furthermore, within a specific tenant organization, a dynamic URL can change the page it references over time. In other examples described herein, the URL can be a static URL associated with the same single-page application, regardless of any user-driven settings defined in the tenant account.
[0012] The router is configured to determine whether a match exists between a portion of the URL and an entry stored in the routing table. In various examples, this matching is based on a routing path, which is a URL relative to the hostname with the query string removed. In other words, the routing path is the remainder of the URL after removing the hostname and query string. Using a routing path instead of the entire URL optimizes the process for determining a match and reduces the chance of errors when the system compares short strings. The routing path is normalized (e.g., including only lowercase letters) to ensure valid and efficient matching. Depending on whether the URL is dynamic or static, the routing path can be either a dynamic or static routing path. In the case of a match (e.g., a cache hit), the service worker is configured to use the entry to identify the single-page application referenced by the routing path and invoke the corresponding application controller for that single-page application.
[0013] There are various ways in which service workers use entries to populate routing tables. For example, when an application controller is downloaded and / or installed, static URLs (e.g., static route paths) can be loaded into the routing table. Application controllers for single-page applications can include attributes that define static URLs belonging to the single-page application. Because the pages referenced by static URLs are consistent across tenant accounts (i.e., they are not driven by user- or tenant-defined settings), entries based on these static URLs can be added to the routing table immediately, even if the user does not request the loading and execution of the corresponding single-page application's static URLs in the browser. Therefore, initial access to static URLs can be handled locally by the service worker and the application controller invoked by the service worker.
[0014] In another example, a dynamic URL (e.g., a dynamic route path) can be loaded into the routing table in association with an initial access to the corresponding page in the root directory. That is, when a request for a URL associated with a dynamic route path is first received, the service worker allows the request to be routed to the web server because there is no matching entry for the dynamic route path in the routing table (e.g., a cache miss). The web server stores user-driven settings that define the single-page application referenced by the dynamic route path. The web server is configured to respond to the request and include an identifier in the response header mapping the dynamic URL to the single-page application. The service worker intercepts the response and adds an entry to the routing table, allowing the service worker and the invoked application controller to handle subsequent requests for the dynamic URL locally.
[0015] Therefore, the service worker disclosed herein acts as a coordinator for multiple application controllers, each serving a customized application experience. The service worker proxies various lifecycle events (e.g., installation, activation, etc.) for registered application controllers and coordinates the execution of these lifecycle events by relying on entries in the routing table that identify the appropriate single-page application. Unlike conventional single-page application systems that provide a strict one-to-one association between service workers and single-page applications, the disclosed service worker can serve multiple single-page applications simultaneously (e.g., implementing a one-to-N association). This alleviates the need to unregister source and target service workers, which severely impacts the performance of computational systems. Once loaded, the service worker disclosed herein can persist across application boundaries, but within a defined root scope, thereby allowing multiple single-page applications and / or application controllers to share resources efficiently and effectively. This improves subsequent load times for web content and allows for a seamless end-user experience.
[0016] This summary is provided to introduce a selection of concepts in a simplified form, which are further described in the detailed description below. This summary is not intended to identify key or essential features of the claimed subject matter, nor is it intended to determine the scope of the claimed subject matter. For example, the term "technology" may refer to one or more systems, methods, computer-readable instructions, modules, algorithms, hardware logic units, and / or operations permitted in the context described above and throughout this document. Attached Figure Description
[0017] A detailed description is provided with reference to the accompanying drawings. In the drawings, the leftmost numeral(s) of a reference numeral(s) identifies the figure in which the reference numeral(s) first appear. The same reference numeral(s) in different drawings indicate similar or identical items. References to individual items among multiple items can be made using reference numerals with letters from the alphabetical sequence to refer to each individual item. General references to items can be made using specific reference numerals without the alphabetical sequence.
[0018] Figure 1 is a diagram illustrating an exemplary environment in which service workers are configured to host multiple single-page applications (SPAs) within the same Uniform Resource Locator (URL) space (e.g., the domain within which the SPA is hosted).
[0019] Figure 2 This is a diagram illustrating an exemplary environment in which a service worker and an application controller corresponding to a single-page application served by the service worker are downloaded and installed on a user device.
[0020] Figure 3 This is an example diagram illustrating how a service worker can be configured to match the routing path of a requested URL with the routing path of an entry in a routing table and use the entry to determine the single-page application referenced by the requested URL.
[0021] Figure 4 This is a diagram illustrating the components used by the application controller to perform lifecycle operations.
[0022] Figure 5 This is a flowchart illustrating an exemplary method in which multiple single-page applications (SPAs) are hosted in the same Uniform Resource Locator (URL) space (e.g., within a domain that hosts the SPA).
[0023] Figure 6 This diagram illustrates how client-side identifiers are used to associate a single-page application with one of several web pages hosted by the single-page application, which are currently displayed by the browser in different tabs or windows.
[0024] Figure 7 It is a computer architecture diagram, which illustrates the illustrative computer hardware and software architecture of a computing system capable of implementing various aspects of the technologies and techniques proposed in this paper.
[0025] Figure 8 This is a diagram illustrating a distributed computing environment capable of implementing various aspects of the technologies and techniques proposed in this paper. Detailed Implementation
[0026] The following detailed description discloses techniques and methods for implementing a service worker capable of serving multiple single-page applications (SPAs) hosted in the same Uniform Resource Locator (URL) space (e.g., a domain hosting the SPAs within it). Therefore, the scope of the service worker is no longer defined by a single SPA, but rather by the root directory of the website hosting multiple SPAs. Since the service worker described herein serves multiple SPAs, it implements a scheme to ensure that the correct application controller corresponding to the SPA hosting the URL is invoked. To this end, the service worker is configured to utilize routers and routing tables to associate the URL included in a request from a browser with the correct application controller corresponding to the SPA hosting the URL that sends the request to it.
[0027] In various examples, the URL can be a dynamic URL, which, depending on user-driven settings defined in the tenant account, can be associated with different single-page applications (SPAs) served by the service worker. Furthermore, within a specific tenant organization, a dynamic URL can change the page it references over time. Therefore, the URL space to which multiple SPAs belong can be referred to herein as a dynamic URL space, at least because it includes one or more dynamic URLs. In other examples described herein, the URL can be a static URL associated with the same single-page application, regardless of any user-driven settings defined in the tenant account.
[0028] The following is for reference Figure 1-8 Various examples, scenarios, and aspects of the disclosed technology are described.
[0029] Figure 1 This is a diagram illustrating an exemplary environment 100, where service workers are configured to host multiple single-page applications (SPAs) within the same Uniform Resource Locator (URL) space (e.g., a domain hosting the SPAs within it). (As shown in...) Figure 1 As shown, user device 102 is executing browser 104, which displays web pages in windows and / or tabs. As part of this execution, browser 104 is configured to initiate requests for URLs corresponding to the displayed web pages, as referenced by 106.
[0030] User device 102 may include, but is not limited to: desktop computers, game consoles and / or gaming devices, tablet computers, personal data assistants (PDAs), mobile phone / tablet hybrid devices, laptop computers, telecommunications equipment, wearable devices, workstations, augmented or virtual reality devices, Internet of Things (IoT) devices, embedded devices, or any other type of computing device configured to use browsing components to display web pages.
[0031] A service worker 108, configured on user device 102 and located between browser 104 and one or more web servers 110 accessible by user device 102 via network(s)112, intercepts the request. The service worker 108 is a script executed in the background by browser 104, separate from the thread executing the displayed webpage. The service worker 108 is defined within the root directory 114 of a website (e.g., 'www.contoso.com') hosting multiple single-page applications 116 (1-N) (where N is a positive number, such as 2, 3, 5, 10, etc.). For example, single-page applications could be calendar applications, email applications, search applications, list applications, etc.
[0032] Each of the multiple single-page applications 116 (1-N) is associated with its own application controller 118 (1-N) installed on user equipment 102. By using the application controller 118 (1-N), the single-page application 116 (1-N) is able to define its own offline experience (e.g., boot sequence) without having to access or receive files and / or instructions from one or more network servers 110 via a connection established on one or more networks 112.
[0033] Application controllers 118 (1-N) are each configured to manage the service worker lifecycle and provide various operations based on the lifecycle. Since service worker 108 serves multiple single-page applications 116 (1-N), service worker 108 implements a scheme to ensure that the correct application controller corresponding to the single-page application hosting the URL is invoked. To this end, service worker 108 is configured to utilize router 120 and routing table 122 to associate the URL included in a request from a browser (such as that referenced by 106) with the correct application controller of the single-page application hosting the webpage for which the request is sent.
[0034] After the request is intercepted by service worker 108, router 120 is configured to identify the URL that provides the basis for a search in routing table 122. Routing table 122 includes different entries that associate a URL or part of a URL with an identifier of one of the single-page applications 116 (1-N). Therefore, router 120 is configured to determine whether there is a match between the URL associated with the request and the URL listed in the entry of routing table 122. In different examples, the match is based on a routing path relative to the hostname of the URL with the query string removed. In other words, the routing path is the remaining part of the URL after removing the hostname and query string. Thus, if the URL is 'www.contoso.com / site1 / page2 / querystring', then the routing path would be 'site1 / page2'.
[0035] Using a route path instead of the entire URL optimizes the matching process and reduces the chance of errors, as server worker 108 is able to compare shorter strings. The route path is normalized (e.g., includes only lowercase letters) to ensure efficient and effective matching. In the case of entry match 124 (e.g., cache hit), server worker 108 is configured to use the matching entry to identify one of the single-page applications 116 (1-N) referenced by the route path. For example, the URL associated with the request may be associated with single-page application 116 (1), and therefore, entry matching reveals the identifier of single-page application 116 (1). Using the identifier, server worker 108 invokes the corresponding application controller 118 (1) for single-page application 116 (1). That is, server worker 108 coordinates or triggers the execution of an event based on the request by invoking application controller 118 (1).
[0036] If no entry matches 126 (e.g., a cache miss), the service worker 108 does not further interfere with the request and forwards the request to one or more web servers 110 for processing, as further described herein.
[0037] Figure 2 The diagram illustrates an exemplary environment 200, in which service worker 108 and application controller 118(1-N) corresponding to single-page applications 116(1-N) served by service worker 108 initially reside on one or more web servers 110, but are downloaded and installed on user equipment 102 via one or more networks 112.
[0038] The browser on user device 102 is configured to download and / or install service worker 108, application controllers 118 (1-N), and other data (e.g., files) for single-page applications 116 (1-N) upon initial network access 202 to web pages (e.g., homepage or welcome page) hosted within root directory 114. Root directory 112 defines the scope for service worker 108.
[0039] Figure 2The illustration shows that each application controller in application controllers 118 (1-N) defines its own offline experiences 204, 206, 208. For example, offline experiences 204, 206, 208 can include bootstrap sequences for single-page applications, which can be implemented once service worker 108 and application controllers 118 (1-N) are downloaded to user device 102 without having to access or receive files from web server(s)110. Providing single-page application developers with the flexibility to control offline scenarios is important because different single-page applications can handle content loading and / or synchronization differently to optimize the user experience. Therefore, when service worker 108 is configured to serve multiple single-page applications 116 (1-N), service worker 108 enables different experiences 204, 206, 208 to be executed via separate application controllers 118 (1-N) associated with single-page applications 116 (1-N).
[0040] The URL can be a dynamic URL, which can be associated with different single-page applications (SPAs) among the SPAs 116 (1-N) served by service worker 108 based on user-driven settings that define dynamic URLs and / or routing paths in tenant account 210. That is, the settings associate a dynamic URL with one of the SPAs 116 (1-N). Alternatively, the URL can be a static URL associated with the same SPA, regardless of any user-driven settings. In other words, the association between a static URL and a SPA is the same across tenant accounts (e.g., there is no user-controlled aspect regarding which SPA the URL references).
[0041] There are various methods, among which the service worker 108, once installed and registered on the user equipment 102, utilizes entry population. Figure 1 The routing table 122 is used for example. Static route paths 212, 214, and 216 are part of application controllers 118 (1-N) and can be loaded into routing table 122 when application controllers 118 (1-N) are downloaded to and / or installed on user device 102. Application controllers 118 (1-N) can include attributes that define static route paths 212, 214, and 216. Because the pages referenced by static URLs are consistent across tenant accounts (i.e., they are not driven by user- or tenant-defined settings), entries based on these static URLs can be added to routing table 122 immediately, even if the user does not request that static URLs be loaded and executed in the browser. Therefore, initial access to a static URL results in an entry match (e.g., a cache hit) and can be processed locally by service worker 108, which has already been downloaded to user device 102.
[0042] Conversely, a dynamic URL (e.g., a dynamic route path) is loaded into routing table 122 in association with an initial access to its corresponding page in root directory 114. When service worker 108, executing on user device 102, first receives a request for the URL associated with the dynamic route path, service worker 108 allows the request to be forwarded to one or more web servers 110 because there is no matching entry for the dynamic route path in routing table 122 (e.g., a cache miss). One or more web servers 110 are able to determine the association between the dynamic route path and the identity of the single-page application by examining settings defined in the tenant account. One or more web servers 110 are configured to respond to the request and map the dynamic URL to the identity of the single-page application in the header of the response. Service worker 108, executing on user device 102, intercepts the response and adds the entry to routing table 122, so that subsequent requests for the same dynamic URL executed by the browser can be handled locally by service worker 108.
[0043] Therefore, the service worker 108 executing on user device 102 acts as a coordinator for multiple application controllers, each serving a customized offline application experience. The service worker proxies various lifecycle events (e.g., installation, activation, etc.) for registered application controllers and coordinates the execution of these lifecycle events by relying on entries in the routing table that identify the appropriate single-page application. Unlike conventional single-page application systems, the exposed service worker is capable of serving multiple single-page applications simultaneously. Once loaded, the service worker can persist across application boundaries, but within a defined root scope, thereby allowing multiple single-page applications to share resources efficiently and effectively. This improves subsequent load times for web content and allows for a seamless end-user experience.
[0044] Figure 3 Figure 300 illustrates an example of how a service worker is configured to match the routing path of a requested URL with the routing path of an entry in a routing table, and uses the entry to determine the single-page application referenced by the requested URL. Figure 3 The illustration shows the main thread 302 executed by the browser on the user's device. The main thread displays four web pages in four different windows and / or tabs. The first web page includes 'www.contoso.com' 304, the second web page includes 'www.contoso.com / site2 / page3' 306, the third web page includes 'www.acme.com / site1 / page1' 308, and the fourth web page includes 'www.contoso.com / site3 / page2' 310. Figure 3The illustration also shows a separate thread 312 in which the browser executes the service worker 108.
[0045] As previously described, in at least one example, the definition scope 314 of the service worker is all single-page applications hosted for the root directory of a website, such as 'www.contoso.com' 316. In this example, at least some of these single-page applications include "Sitel", "Site2", and "Site3", and each of these single-page applications is capable of including multiple different pages.
[0046] Service worker 108 is configured to intercept requests for URLs 304, 306, 308, and 310 displayed in the browser and determine whether the request is within its scope. Therefore, service worker 108 is configured to process requests for 'www.contoso.com' (304), 'www.contoso.com / site2 / page3' (306), and 'www.contoso.com / site3 / page2' (310) because they are within its scope. However, service worker 108 is not configured to process the request for 'www.acme.com / site1 / page1' (308) because that webpage is not within its scope.
[0047] After service worker 108 determines that the request is within its boundary based on defined range 314, router 120 checks routing table 122 for a match. Figure 3 In the example, routing table 122 includes a first entry that associates the root (' / ') route path for URL 'www.contoso.com' 304 with the application identifier for SPA "Site1". Routing table 122 includes a second entry that associates the route path "site2 / page3" for URL 'www.contoso.com / site2 / page3' 306 with the application identifier for SPA "site2". Routing table 122 includes a third entry that associates the route path "site3 / page2" for URL 'www.contoso.com / site3 / page2' 310 with the application identifier for SPA "site3".
[0048] In the case of a match (e.g., a hit), these entries are used to identify the single-page application corresponding to the request. As described above, the routing path in the entries can be a dynamic routing path (e.g., the root ' / ' can be configured to access the SPA for 'site1', 'site2', or 'site3') or a static routing path (e.g., 'site2 / page3' can be configured to access the SPA for 'site2' only).
[0049] In various examples, service worker 108 can perform pattern matching within dynamic routing paths to increase the match rate or cache hit rate when no exact match exists for the entire routing path. The pattern matching can use one or more segments as predicates to improve the match rate. This ultimately saves resources (e.g., network resources) and reduces latency because requests do not need to be processed by a web server. For example, if the 'site1' single-page application within 'www.contoso.com' hosts 'page1' and 'page2', and a user has visited 'www.contoso.com / site1 / page1', and then the user visits 'www.contoso.com / site1 / page2', then service worker 108 can use pattern matching of one or more segments (e.g., 'site1') in both routing paths (e.g., 'site1' and 'site1 / page2') to determine that 'www.contoso.com / site1 / page2' is also associated with the 'site1' single-page application. This allows for local calls to the application controller without having to go to the network.
[0050] Figure 4 Figure 400 illustrates components used by application controller 402 to manage and execute lifecycle operations for a single-page application. Exemplary lifecycle operations may include installation, activation, deactivation, request handling, synchronization, messaging, etc. In some embodiments, application controller 402 invokes application handler 404 in response to navigation requests (such as fetch events) and / or other resource requests. In some embodiments, application controller 402 invokes application handler 404 to render dynamic HTML using streaming responses. In some embodiments, application controller invokes application configuration 406 to provide access to runtime configuration data stored in file 408 of local data storage 410.
[0051] Figure 5 Indicates that according to from Figure 1-4 The description provides various examples of exemplary processes. Figure 5The exemplary operations shown can be implemented or otherwise embodied on user equipment 102 or other types of devices via a service worker.
[0052] The order in which the operations are described is not intended to be construed as limiting, and any number of the operations can be combined in any order and / or in parallel to achieve the process. Furthermore, in Figure 5 The operations described herein can be implemented in hardware, software, and / or a combination thereof. In the context of software, an operation represents computer-executable instructions that, when executed by one or more processing units, cause one or more processing units to perform the operation. For example, the modules and components described herein can be stored in a computer-readable medium and executed by at least one processing unit to perform the described operations.
[0053] Figure 5 This is a flowchart of an exemplary method 500 for a service worker to serve multiple single-page applications (SPAs) hosted in the same Uniform Resource Locator (URL) space (e.g., a domain within which the SPA is hosted).
[0054] At operation 502, a request from a browser executing on the user's device is intercepted. The request is associated with the URL of a webpage displayed via the browser. At operation 504, at least a portion of the URL associated with the request matches a routing path in an entry in the routing table. At operation 506, an identifier for one of the multiple single-page applications is determined from the entries in the routing table. At operation 508, execution of the application controller associated with one of the multiple single-page applications is invoked to process the request associated with the URL.
[0055] Figure 6 Figure 600 illustrates the use of client-side identifiers to associate a single-page application with different web pages among multiple web pages hosted by the single-page application, which are currently displayed by a browser in different tabs or windows. In other words, client-side identifiers can be used when multiple instances of the same single-page application (e.g., different URLs) are executed via a browser.
[0056] As illustrated, the main thread of browser 602 displays web pages for 'www.contoso.com / site1 / page1' 604, 'www.contoso.com / site1 / page2' 606, and 'www.contoso.com / site1 / page3' 608. Each of these URLs is hosted by the same single-page application 610 ('site1').
[0057] Therefore, upon the first navigation request for each URL 604, 606, 608, the service worker 108 can assign client identifiers 614, 616, 618 to URLs 604, 606, 608, ensuring that messages from each URL 604, 606, 608 executed in the browser are mapped to the correct application controller 620, and that resources are appropriately provided to the different URLs 604, 606, 608 of the single-page application 610. These client identifiers 614, 616, 618 can be used to populate the routing table.
[0058] Figure 7 Additional details are shown of an exemplary computer architecture 700 for a device capable of executing computer instructions (e.g., a service worker as described herein). Figure 7 The computer architecture 700 illustrated includes: one or more processing units 702, a system memory 704 including random access memory 706 (“RAM”) and read-only memory (“ROM”) 708, and a system bus 710 coupling the memory 704 to the processing unit 702.
[0059] One or more processing units (such as processing unit 702) can represent, for example, a CPU-type processing unit, a GPU-type processing unit, a field-programmable gate array (FPGA), another type of digital signal processor (DSP), or other hardware logic components that can be driven by a CPU in some cases. For example, but not limited to, illustrative types of hardware logic components that can be used include application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), etc.
[0060] The basic input / output system is stored in ROM 508, which contains basic routines, for example, that help transfer information between components within computer architecture 700 during startup. Computer architecture 700 also includes a mass storage device 712 for storing operating system 714, applications 716 (e.g., a browser), components 718 (e.g., server workers, etc.), and other data described herein.
[0061] Mass storage device 712 is connected to processing unit 702 via a mass storage controller connected to bus 710. Mass storage device 712 and its associated computer-readable medium provide non-volatile storage for computer architecture 700. Although the description of computer-readable medium contained herein refers to mass storage device, those skilled in the art will understand that computer-readable medium can be any available computer-readable storage medium or communication medium accessible by computer architecture 700.
[0062] Computer-readable media may include computer storage media and / or communication media. Computer storage media may include one or more of volatile memory, non-volatile memory and / or other persistent and / or auxiliary computer storage media, removable and non-removable computer storage media, implemented by any method or technique for storing information such as computer-readable instructions, data structures, program modules or other data. Therefore, computer storage media includes media in tangible and / or physical form, which are contained in devices and / or as part of or outside of devices, including but not limited to random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), phase-change memory (PCM), read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory, optical disc read-only memory (CD-ROM), digital multifunction disc (DVD), optical cards or other optical storage media, cassette tape, magnetic tape, disk storage devices, magnetic cards or other magnetic storage devices or media, solid-state storage devices, storage arrays, network-attached storage devices, storage area networks, hosted computer storage devices, or any other storage memory, storage device, and / or storage medium that can be used to store and maintain information accessible to computing devices.
[0063] Unlike computer storage media, communication media can contain computer-readable instructions, data structures, program modules, or other data, such as carrier waves or other transmission mechanisms, within modulated data signals. As defined herein, computer storage media does not include communication media. In other words, computer storage media does not include communication media consisting solely of modulated data signals, carrier waves, or propagating signals themselves.
[0064] Depending on the configuration, computer architecture 700 can operate in a networked environment using a logical connection to a remote computer via network 720. Computer architecture 700 can be connected to network 720 via network interface unit 722 connected to bus 710. Computer architecture 700 may also include input / output controller 724 for receiving and processing input from many other devices, including keyboards, mice, touchscreens, or electronic styluses or pens. Similarly, input / output controller 724 can provide output to displays, printers, or other types of output devices.
[0065] Network 720 may include, for example, a public network such as the Internet, a private network such as an institutional and / or personal intranet, or some combination of private and public networks. Network 720 may also include any type of wired and / or wireless network, including but not limited to Local Area Network (LAN), Wide Area Network (WAN), satellite network, cable network, Wi-Fi network, WiMax network, mobile communication network (e.g., 3G, 4G, etc.), or any combination thereof. Network 720 may utilize communication protocols, including packet-based and / or datagram-based protocols, such as Internet Protocol (IP), Transmission Control Protocol (TCP), User Datagram Protocol (UDP), or other types of protocols. Furthermore, network 720 may include multiple devices that facilitate network communication and / or form the hardware infrastructure of the network, such as switches, routers, gateways, access points, firewalls, base stations, repeaters, backbone equipment, etc.
[0066] It should be understood that, when loaded into and executed, the software components described herein can transform the processing unit 702 and the entire computer architecture 700 from a general-purpose computing system into a special-purpose computing system tailored to facilitate the functions presented herein. The processing unit 702 can be composed of any number of transistors or other discrete circuit elements, which can have any number of states individually or collectively. More specifically, the processing unit 702 can operate as a finite state machine in response to executable instructions contained in the software modules disclosed herein. These computer-executable instructions can transform the processing unit 702 by specifying how it transitions between states, thereby transforming the transistors or other discrete hardware elements constituting the processing unit 702.
[0067] Figure 8 An illustrative distributed computing environment 800 is depicted in which the techniques described herein can be implemented. For example, the distributed computing environment 800 may include resources that can provide services to user devices.
[0068] Therefore, the distributed computing environment 800 may include a computing environment 802 that operates on, communicates with, or is part of the network 804. The network 804 may include various access networks. One or more client devices 806A-806N (collectively and / or generally referred to as “client 806”, and also referred to herein as computing device 806) may communicate with the computing environment 802 via the network 804. In one illustrated configuration, client 806 includes computing device 806A, such as a laptop computer, desktop computer, or other computing device; tablet or rack-mount computing device (“tablet computing device”) 806B; mobile computing device 806C, such as a mobile phone, smartphone, or other mobile computing device; server computer 806D; and / or other devices 806N. It should be understood that any number of clients 806 may communicate with the computing environment 802.
[0069] In various examples, the computing environment 802 includes a server 808, a data storage device 810, and one or more network interfaces 812. The server 808 can host various services, virtual machines, portals, and / or other resources. In the configuration shown, the server 808 hosts a virtual machine 814, a web portal 816, an email service 818, a storage service 820, and / or a social networking service 822. Figure 8 As shown, server 808 can also host other services, applications, portals, and / or other resources (“Other Resources”) 824. Such services may include single-page applications configured to render and display web pages via a browser.
[0070] As described above, computing environment 802 may include data storage device 810. Depending on the implementation, the functionality of data storage device 810 may be provided by one or more databases operating on or communicating with network 804. The functionality of data storage device 810 may also be provided by one or more servers configured to host data for computing environment 802. Data storage device 810 may include, host, or provide one or more real or virtual data storage devices 826A-826N (collectively and / or generally referred to as “data storage 826”). Data storage 826 is configured to host data and / or other data used or created by server 808. In other words, data storage 826 may also host or store web page documents, Word documents, presentation documents, data structures, algorithms executed by recommendation engines, and / or other data used by any application. Aspects of data storage 826 may be associated with services for storing files.
[0071] The computing environment 802 can communicate with or be accessed by the network interface 812. The network interface 812 may include various types of network hardware and software to support communication between two or more computing devices, including but not limited to computing devices and servers. It should be understood that the network interface 812 can also be used to connect to other types of networks and / or computer systems.
[0072] It should be understood that the distributed computing environment 800 described herein can provide any number of virtual computing resources and / or other distributed computing functions for any aspect of the software elements described herein, and can be configured to perform any aspect of the software components disclosed herein. Depending on various implementations of the concepts and techniques disclosed herein, the distributed computing environment 800 provides software functionality as a service to computing devices. It should be understood that computing devices can include physical or virtual machines, including but not limited to server computers, web servers, personal computers, mobile computing devices, smartphones, and / or other devices. Therefore, the various configurations of the concepts and techniques disclosed herein enable any device configured to access the distributed computing environment 800 to utilize the functionality described herein to provide the technologies disclosed herein, as well as other aspects.
[0073] The disclosures presented herein also include the topics described in the following clauses.
[0074] Example Item A, a computer-implemented method for a service worker to serve multiple single-page applications hosted in a dynamic Uniform Resource Locator (URL) space, comprising: intercepting a request from a browser executing on a user device, the request being associated with a URL of a webpage displayed via the browser; matching at least a portion of the URL associated with the request with a routing path in an entry of a routing table; determining an identifier of one of the multiple single-page applications served by the service worker based on the entry of the routing table; and invoking execution of an application controller associated with the one of the multiple single-page applications to process the request associated with the URL.
[0075] Exemplary Clause B, a computer-implemented method of Exemplary Clause A, wherein: the application controller is configured to manage lifecycle operations for one of the plurality of single-page applications; and the lifecycle operations include one or more of the following: installation operation, activation operation, request processing operation, synchronization operation, or messaging operation.
[0076] A computer-implemented method of Exemplary Clause C, Exemplary Clause A, or Exemplary Clause B, wherein the application controller is configured to process the request based on an experience defined by one of the plurality of single-page applications.
[0077] Exemplary Clause D, a computer-implemented method of any one of Exemplary Clauses A through C, wherein the application controller is executed separately from other application controllers associated with other single-page applications among the plurality of single-page applications.
[0078] A computer-implemented method according to any one of Exemplary Clauses E, Exemplary Clauses A through D, wherein the routing path includes a static routing path, and the method further includes: installing the service worker and the application controller before intercepting the request; and, during the installation of the service worker and the application controller, populating the routing table with the entry including the static routing path according to attributes defined in the application controller.
[0079] Exemplary Clause F, a computer-implemented method of any one of Exemplary Clauses A through D, wherein the routing path includes a dynamic routing path that can be configured to access different single-page applications among the plurality of single-page applications based on settings defined by a tenant of a cloud-based platform hosting the plurality of single-page applications.
[0080] The computer-implemented method of Exemplary Clause G and Exemplary Clause F further includes, when the URL is initially accessed by the browser, populating the routing table with the entry including the dynamic routing path based on an intercepted response from a web server, wherein the header of the intercepted response maps the dynamic routing path to the identifier of the one of the plurality of single-page applications.
[0081] A computer-implemented method of any one of Exemplary Clause H, Exemplary Clauses A through G, wherein the scope defined for the service worker includes the root directory for a website that includes the dynamic URL space.
[0082] A computer-implemented method of any one of Exemplary Clauses I, A through H, wherein the matching of at least a portion of the URL associated with the request with the routing path in the entry of the routing table includes pattern matching of one or more path segments.
[0083] The computer-implemented method according to any one of Exemplary Clauses J, A to I, further includes: assigning a plurality of client identifiers to a plurality of instances of the one single-page application among the plurality of single-page applications running in the browser; and populating the routing table with the plurality of client identifiers to enable the service worker to route messages between the plurality of instances of the one single-page application among the plurality of single-page applications running in the browser and the application controller.
[0084] Example Item K: An apparatus for a service worker to serve multiple single-page applications hosted in a dynamic Uniform Resource Locator (URL) space, comprising: one or more processing units; and a computer-readable storage medium storing instructions that, when executed by the one or more processing units, cause the apparatus to perform operations including: intercepting a request from a browser executing on a user device, the request being associated with a URL of a webpage displayed via the browser; matching at least a portion of the URL associated with the request with a routing path in an entry of a routing table; determining an identifier of one of the plurality of single-page applications based on the entry of the routing table; and invoking the execution of an application controller associated with the one of the plurality of single-page applications to process the request associated with the URL.
[0085] The device of Exemplary Clause L and Exemplary Clause K, wherein the application controller is configured to process the request based on an experience defined by one of the plurality of single-page applications.
[0086] The device of Exemplary Clause M, Exemplary Clause K, or Exemplary Clause L, wherein the application controller is executed separately from other application controllers associated with other single-page applications in the plurality of single-page applications.
[0087] A device of any one of Exemplary Clause N, Exemplary Clauses K to M, wherein the routing path includes a static routing path, and the operation further includes: installing the application controller before intercepting the request; and, upon installation of the application controller, populating the routing table with the entry including the static routing path according to attributes defined in the application controller.
[0088] The device of any one of Exemplary Clause O and Exemplary Clauses K through M, wherein the routing path includes a dynamic routing path that can be configured to access different single-page applications among the plurality of single-page applications based on settings defined by the tenant of the cloud-based platform hosting the plurality of single-page applications.
[0089] The device of Exemplary Clause P and Exemplary Clause O, wherein the operation further includes, when the URL is initially accessed by the browser, populating the routing table with the entry including the dynamic routing path based on an intercepted response from the web server, wherein the header of the intercepted response maps the dynamic routing path to the identifier of the one of the plurality of single-page applications.
[0090] The device of any one of Exemplary Clause Q, Exemplary Clauses K to P, wherein the operation is performed by the server worker, and the scope defined for the server worker includes the root directory for the website that includes the dynamic URL space.
[0091] The device of any one of Exemplary Clause R, Exemplary Clauses K to Q, wherein at least a portion of the URL associated with the request matches the routing path in the entry of the routing table, including a pattern match of one or more path segments.
[0092] An apparatus of any one of Exemplary Clause S, Exemplary Clauses K to R, wherein the operation further includes: assigning a plurality of client identifiers to a plurality of instances of the one single-page application among the plurality of single-page applications running in the browser; and populating the routing table with the plurality of client identifiers such that the service worker is able to route messages between the plurality of instances of the one single-page application among the plurality of single-page applications running in the browser and the application controller.
[0093] Exemplary Clause T, a computer-readable storage medium storing instructions that, when executed by one or more processing units, cause a device to perform operations including: intercepting a request from a browser executing on a user device, the request being associated with a URL of a webpage displayed via the browser; matching at least a portion of the URL associated with the request with a routing path in an entry of a routing table; determining an identifier of one of a plurality of single-page applications based on the entry of the routing table; and invoking the execution of an application controller associated with the one of the plurality of single-page applications to process the request associated with the URL.
[0094] Encoding the software modules presented herein can also transform the physical structure of the computer-readable medium presented herein. In the different implementations described herein, the specific transformation of the physical structure may depend on various factors. Examples of such factors may include, but are not limited to, the technology used to implement the computer-readable medium, whether the computer-readable medium is primary or secondary storage, and so on. For example, if the computer-readable medium is implemented as a semiconductor-based memory, the software disclosed herein can be encoded on the computer-readable medium by transforming the physical state of the semiconductor memory. For example, the software can transform the state of transistors, capacitors, or other discrete circuit elements constituting the semiconductor memory. The software can also transform the physical state of these components to store data thereon.
[0095] Conditional language such as “can,” “may,” “possibly,” or “may,” unless otherwise specifically stated, is understood in context to indicate that certain examples include certain features, elements, and / or steps while others do not. Therefore, such conditional language is not generally intended to imply that certain features, elements, and / or steps are required in any way for one or more examples, or that one or more examples must include logic for determining whether certain features, elements, and / or steps are included or will be performed in any particular example, with or without user input or prompts. Connective language such as the phrase “at least one of X, Y, or Z,” unless otherwise specifically stated, should be understood to indicate that items, terms, etc., can be X, Y, or Z, or combinations thereof.
[0096] The terms “a,” “an,” “the,” and similar designations used in the context of describing the invention (particularly in the context of the appended claims) should be interpreted as including both the singular and the plural, unless otherwise indicated herein or clearly contradicted by the context. The terms “based on,” “based upon,” and similar designations should be interpreted as meaning “at least partially based,” including both “partially based” and “ wholly based,” unless otherwise stated or clearly contradicted by the context.
[0097] It should be understood that any reference to elements such as "first" and "second" in the synopsis and / or description is not intended and should not be construed as necessarily corresponding to any reference to elements such as "first" and "second" in the claims. Rather, any use of "first" and "second" in the synopsis, description, and / or claims can be used to distinguish two different instances of the same element (e.g., two different single-page applications, two different operations, etc.).
[0098] Finally, although various configurations have been described in a language specific to structural features and / or method actions, it should be understood that the subject matter defined in the appended representations is not necessarily limited to the specific features or actions described. Rather, specific features and actions are disclosed as exemplary forms for implementing the claimed subject matter. All examples are provided for illustrative purposes and should not be construed as limiting.
Claims
1. A computer-implemented method for a service worker to serve multiple single-page applications hosted in a dynamic Uniform Resource Locator (URL) space, comprising: Install the service worker and the application controller associated with the single-page application in the plurality of single-page applications served by the service worker, wherein each single-page application in the plurality of single-page applications has an associated application controller; When installing the service worker and the application controller, the routing table is populated with entries including static route paths, based on the attributes defined in the application controller. After the service worker is installed and the routing table is populated with the entries, the service worker intercepts requests from a browser running on the user's device, the requests being associated with the URL of a webpage displayed via the browser; At least a portion of the URL associated with the request is matched against the static route path included in the entry in the routing table; The identifier of the single-page application is determined based on the entry in the routing table; and The execution of the application controller associated with the single-page application is invoked to process the request associated with the URL.
2. The computer-implemented method according to claim 1, wherein: The application controller is configured to manage lifecycle operations for the single-page application; and The lifecycle operations include one or more of the following: installation operations, activation operations, request processing operations, synchronization operations, or message operations.
3. The computer-implemented method according to claim 1, wherein, The application controller is configured to handle the request based on the experience defined by the single-page application.
4. The computer-implemented method according to claim 1, wherein, The application controller is executed separately from other application controllers associated with other single-page applications among the plurality of single-page applications.
5. The computer-implemented method according to claim 1, wherein, The scope defined for the service worker includes the root directory of the website that includes the dynamic URL space.
6. The computer-implemented method according to claim 1, wherein, The matching of at least a portion of the URL associated with the request with the static route path included in the entry in the routing table includes a pattern match of one or more path segments.
7. The computer-implemented method according to claim 1, further comprising: Assign multiple client identifiers to multiple instances of the single-page application running in the browser; as well as The routing table is populated using the multiple client identifiers so that the service worker can route messages between the multiple instances of the single-page application running in the browser and the application controller.
8. An apparatus for a service worker to serve multiple single-page applications hosted in a dynamic Uniform Resource Locator (URL) space, comprising: One or more processing units; as well as A computer-readable storage medium storing instructions that, when executed by the one or more processing units, cause the device to perform operations including: Intercept requests from a browser running on a user's device, the requests being associated with the URL of a webpage displayed via the browser; At least a portion of the URL associated with the request is matched against a routing path in an entry in the routing table, wherein the routing path includes a dynamic routing path that can be configured to access different single-page applications among the multiple single-page applications based on settings defined by the tenant of the cloud-based platform hosting the multiple single-page applications. The identifier of one of the plurality of single-page applications is determined based on the entry in the routing table; and The execution of the application controller associated with one of the plurality of single-page applications is invoked to process the request associated with the URL, wherein each of the plurality of single-page applications has an associated application controller.
9. The device according to claim 8, wherein, The application controller is configured to process the request based on the experience defined by one of the plurality of single-page applications.
10. The device according to claim 8, wherein, The application controller is executed separately from other application controllers associated with other single-page applications among the plurality of single-page applications.
11. The device according to claim 8, wherein, The operation further includes: when the URL is initially accessed by the browser, populating the routing table with the entry including the dynamic routing path based on the intercepted response from the web server, wherein the header of the intercepted response maps the dynamic routing path to the identifier of the one of the plurality of single-page applications.
12. The device according to claim 8, wherein, The operation is performed by the service worker, and the scope defined for the service worker includes the root directory of the website that includes the dynamic URL space.
13. The device according to claim 8, wherein, The matching of at least the portion of the URL associated with the request with the routing path in the entry of the routing table includes pattern matching of one or more path segments.
14. The device according to claim 8, wherein, The operation also includes: Assigning multiple client identifiers to multiple instances of the single-page application among the multiple single-page applications running in the browser; and The routing table is populated using the multiple client identifiers so that the service worker can route messages between the multiple instances of one of the multiple single-page applications executed in the browser and the application controller.
15. A computer-readable storage medium storing instructions, which, when executed by one or more processing units, cause a device to perform operations including: Assign multiple client identifiers to multiple instances of a single-page application running in the browser of the device; The routing table is populated using the multiple client identifiers so that the service worker can route messages between the multiple instances of the single-page application and the application controller associated with the single-page application; Intercept requests from the browser that are associated with the URL of a webpage displayed via the browser; At least a portion of the URL associated with the request is matched against the routing path in the entry of the routing table; The client identifier among the plurality of client identifiers is determined based on the entry in the routing table; as well as The execution of the application controller associated with the single-page application is invoked to process the request associated with the URL based on the client identifier determined according to the entry in the routing table.
Citation Information
Patent Citations
Software application architecture
CN108139890A
