Browser refresh method and device, electronic device and computer-readable storage medium

By setting the index.html in the browser and listening to SW update events, the two refresh problems during SW updates are solved, and the unconscious SW uninstallation is achieved, improving user experience and uninstall efficiency.

CN113515718BActive Publication Date: 2025-06-06CHINA CONSTRUCTION BANK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110805673.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-07-16
Publication Date
2025-06-06
Estimated Expiration
2041-07-16

AI Technical Summary

Technical Problem

In the prior art, the browser needs to be refreshed twice when the Service worker (SW) is updated, and the user experience is unfriendly and uninstalling the SW requires manual clearing of the browser cache, resulting in high uninstallation costs.

Method used

When SW is deployed in the browser, set not to cache index.html and listen for SW update events. Refresh the browser immediately when an update is detected, and uninstall the SW registration code and files, and trigger refresh through a callback event.

Benefits of technology

It realizes that you only need to refresh the browser once when SW is updated to get the latest version, avoiding the user experience problem of refreshing twice in traditional methods, and automatically uninstalling SW without perception.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113515718B_ABST
    Figure CN113515718B_ABST
Patent Text Reader

Abstract

The present application provides a browser refresh method and device, an electronic device, and a computer-readable storage medium, wherein the method comprises: determining whether SW has been deployed in a target browser; if SW has been deployed, setting not to cache index.html and listening to SW update events; if SW update events are listened to, immediately triggering a refresh of the target browser. The above scheme sets not to cache index.html, so that the latest version can be obtained without refreshing twice, and the updated version can be obtained with only one refresh.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of Internet technology, and in particular, relates to a browser refresh method and device, an electronic device, and a computer-readable storage medium. Background Art

[0002] Progressive Web App (PWA for short) is a web app that uses multiple technologies to enhance its functionality. PWA can make the website experience better and simulate some native functions, such as push notifications. On the mobile side, a standardized framework is used to allow web apps to present an experience similar to native apps, such as a good file caching experience and offline viewing capabilities.

[0003] Service worker (the middleman between the server and the browser, referred to as SW) technology is a technology suitable for offline caching projects. SW technology essentially acts as a proxy server between the web application and the browser, and can also act as a proxy between the browser and the network when the network is available. Service worker is an event-driven worker registered under a specified source and path. It uses JavaScript to control the associated page or website, intercept and modify access and resource requests, and cache resources in a fine-grained manner. If it is a non-offline application, the benefits of using SW technology are not great. Because it is a non-offline application, each resource file is obtained in real time through HTTP, and static resources can also be cached separately on the front end. In the actual use process, there are pain points for each update of the service that enables SW. Based on the update mechanism of SW, each time a new version is released, the page needs to be refreshed twice. Some users cannot accept this unfriendly update method. And if the SW service is enabled, if you want to uninstall it, the user generally needs to manually clear the browser cache, which is bound to bring a large uninstall cost.

[0004] To address the above problems, no effective solution has been proposed yet. Summary of the invention

[0005] The purpose of this application is to provide a browser refresh method and device, an electronic device and a computer-readable storage medium, which can avoid the problem of needing to refresh the browser twice when a new version of SW is updated.

[0006] The present application provides a browser refresh method and device, an electronic device, and a computer-readable storage medium, which are implemented as follows:

[0007] A browser refresh method, the method comprising:

[0008] Determine whether the target browser has deployed the middleman SW between the server and the browser;

[0009] If SW has been deployed, set index.html not to be cached and listen for SW update events;

[0010] When a SW update event is monitored, the target browser is immediately triggered to refresh.

[0011] In one embodiment, after determining that the SW has been deployed, the method further includes:

[0012] Remove the SW registration code and service-worker.js file.

[0013] In one embodiment, after determining that the SW has been deployed, the method further includes:

[0014] Add the code to uninstall SW in index.html;

[0015] Add the code to refresh the browser in the callback event of successfully uninstalling SW.

[0016] In one embodiment, after adding the code for uninstalling SW in index.html, it also includes:

[0017] Receive an uninstall request for SW;

[0018] In response to the uninstallation request, calling and executing the uninstallation SW code in index.html;

[0019] Confirm whether SW has been successfully uninstalled;

[0020] When it is determined that the uninstallation is successful, the target browser is refreshed by calling the browser refresh code through the callback event.

[0021] A browser refresh device, comprising:

[0022] A determination module, used to determine whether a middleman role SW between the server and the browser has been deployed in the target browser;

[0023] The setting module is used to set index.html not to be cached and listen to SW update events when SW is determined to be deployed;

[0024] The trigger module is used to immediately trigger the refresh of the target browser when a SW update event is monitored.

[0025] In one embodiment, the above device further comprises:

[0026] The removal module is used to remove the registration code and service-worker.js file of the SW after confirming that the SW has been deployed.

[0027] In one embodiment, the above device further comprises:

[0028] The first adding module is used to add the code for uninstalling the SW in index.html after determining that the SW has been deployed;

[0029] The second adding module is used to add the code of refreshing the browser in the callback event of successfully uninstalling the SW.

[0030] In one embodiment, the above device further comprises:

[0031] The receiving module is used to receive the uninstallation request for SW after adding the code for uninstalling SW in index.html;

[0032] A calling module, used for calling and executing the code of the uninstall SW in index.html in response to the uninstall request;

[0033] Confirmation module, used to confirm whether SW has been successfully uninstalled;

[0034] The refresh module is used to refresh the target browser by calling the code for refreshing the browser through a callback event when it is determined that the uninstallation has been successful.

[0035] An electronic device includes a processor and a memory for storing instructions executable by the processor, wherein when the processor executes the instructions, the steps of the following method are implemented:

[0036] Determine whether SW has been deployed in the target browser;

[0037] If SW has been deployed, set index.html not to be cached and listen for SW update events;

[0038] When a SW update event is monitored, the target browser is immediately triggered to refresh.

[0039] A computer-readable storage medium having computer instructions stored thereon, wherein the instructions, when executed, implement the steps of the following method:

[0040] Determine whether SW has been deployed in the target browser;

[0041] If SW has been deployed, set index.html not to be cached and listen for SW update events;

[0042] When a SW update event is monitored, the target browser is immediately triggered to refresh.

[0043] The present application provides a browser refresh method, which determines whether SW has been deployed in the target browser. If SW has been deployed in the target browser, it is set not to cache index.html and listen to SW update events; if SW update events are listened, it is immediately triggered to refresh the target browser. By setting not to cache index.html, it can be ensured that the updated version can be obtained by refreshing only once, and the latest version can be obtained without refreshing twice. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0045] Figure 1 It is a method flow chart of an embodiment of the browser refresh method provided by the present application;

[0046] Figure 2 is a method flow chart of the SW update method provided by this application;

[0047] Figure 3 It is a hardware structure block diagram of an electronic device of a browser refresh method provided by the present application;

[0048] Figure 4 This is a structural block diagram of a browser refresh device provided by this application. DETAILED DESCRIPTION

[0049] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.

[0050] Figure 1It is a method flow chart of an embodiment of the browser refresh method provided by the present application. Although the present application provides method operation steps or device structures as shown in the following embodiments or drawings, more or fewer operation steps or module units may be included in the method or device based on routine or no creative labor. In the steps or structures where there is no necessary causal relationship logically, the execution order of these steps or the module structure of the device is not limited to the execution order or module structure described in the embodiments of the present application and shown in the drawings. When the method or module structure is applied to an actual device or terminal product, it can be connected according to the method or module structure shown in the embodiments or drawings for sequential execution or parallel execution (for example, a parallel processor or a multi-threaded processing environment, or even a distributed processing environment).

[0051] Specifically, Figure 1 As shown, the above browser refresh method may include the following steps:

[0052] Step 101: Determine whether SW (middleman role between server and browser) has been deployed in the target browser;

[0053] Step 102: When it is determined that the SW has been deployed, set index.html not to be cached, and listen to the SW update event;

[0054] That is, in order to ensure that the new version of SW can be obtained immediately, the sw.updated event can be monitored. If an update is detected, the browser will be triggered to update immediately. By not caching index.html, the latest index.html and corresponding js files can be obtained immediately. Because index.html is a cached file in SW, removing the cache of index.html at this time can ensure that this version only needs to refresh the page once to obtain the updated version.

[0055] Step 103: When a SW update event is monitored, immediately trigger a refresh of the target browser.

[0056] In order to ensure that users can discover the new version in time, you can refresh the front-end version of the page immediately after deploying the updated SW. That is, after obtaining the SW update, call the browser refresh again immediately. This front-end version setting can ensure that users update to the code file in time.

[0057] In the above example, it is determined whether SW has been deployed in the target browser. If SW has been deployed in the target browser, it is set not to cache index.html and listen to SW update events; if SW update events are listened, the target browser is immediately triggered to refresh. By setting index.html not to cache, it can be ensured that the updated version can be obtained by refreshing only once, and the latest version can be obtained without refreshing twice.

[0058] After confirming that the SW has been deployed, you can remove the SW registration code and service-worker.js file. That is, remove the SW registration code and service-worker.js file, inject the code for uninstalling the SW into index.html, and call the code for refreshing the browser in the callback of successfully uninstalling the SW.

[0059] During implementation, after determining that the SW has been deployed, it may also include: adding the code for uninstalling the SW in index.html; adding the code for refreshing the browser in the callback event of successfully uninstalling the SW. Specifically, after adding the code for uninstalling the SW in index.html, a request for uninstalling the SW may be received; in response to the uninstall request, the code for uninstalling the SW in index.html may be called and executed; confirming whether the SW has been successfully uninstalled; and if it is determined that the SW has been successfully uninstalled, the code for refreshing the browser may be called through the callback event to refresh the target browser. That is, the SW is permanently uninstalled in the current version of index.html. For updated versions of the SW, the client can obtain them normally by refreshing them once. The index.html is also set not to cache. Therefore, the uninstall code for the SW may be written in index.html, and the browser refresh code may be called in the callback event of successful uninstallation. At this point, the SW service may be uninstalled from the client without being noticed.

[0060] The above method is described below in conjunction with a specific embodiment. However, it should be noted that this specific embodiment is only for better illustrating the present application and does not constitute an improper limitation on the present application.

[0061] The existing uninstall SW designs basically require customers to manually clean up the front-end cache to completely remove it. In this case, a progressive deployment solution is proposed, so that for projects that have been launched, the SW service can be uninstalled without the client's awareness, that is, the customer does not need to manually clear the browser cache.

[0062] Specifically, in the progressive deployment solution provided in this example, a progressive deployment method is used with three-stage versions to ensure that most users can access the code of each version and achieve seamless uninstallation. Each version has a certain existence time, so as to ensure that users can access updates. In the actual implementation process, if it is found that the file version of the SW cache is different from the current version, the user can manually clear the browser cache to obtain the latest version of the code.

[0063] When implementing, you can Figure 2 As shown, the following steps are included:

[0064] S1: If SW is confirmed to exist in the browser, the sw.updated event is monitored and the code triggers the browser to update immediately.

[0065] There is a SW service in the server. Each time the version is updated, the browser needs to be refreshed twice to obtain the new version. In order to ensure that users can obtain this new version, the front-end version of the page is refreshed immediately after the SW is deployed and updated. That is, after obtaining the SW update, the browser refresh is called again immediately. This front-end version setting can ensure that users can update to the code file in time.

[0066] S2: Determine not to cache index.html so that the latest index.html and corresponding js files can be obtained immediately. When the SW service exists, the index.html accessed in S1 are all cached files in the SW. At this time, removing the cache of index.html can ensure that this version only needs to refresh the page once to obtain the updated version. In other words, if there is a SW update, you can immediately refresh the browser to obtain it, and filter the cache of index.html in service-worker.js, so that you can get the latest version without refreshing twice.

[0067] The service worker is a script that runs in the background as an independent thread and does not block the page. It essentially acts as a proxy server between the web application and the browser.

[0068] S3: Remove the SW registration code and service-worker.js file, inject the SW uninstall code into index.html, and call the browser refresh code in the callback of successful SW uninstallation. Furthermore, considering that the service-worker file is not removed, the SW uninstall code is written into the new version of index.html. At this time, the SW registration behavior still exists. When SW is uninstalled and the page is refreshed, SW will be registered again, and a loop will be formed. Therefore, it is necessary to remove the service-worker.js file to prevent SW from being registered again, so as to achieve the purpose of permanently uninstalling SW in the current version of index.html. At this time, the updated version can be obtained normally by refreshing the client once, and index.html is also set not to cache, so the SW uninstall code is written into index.html, and the browser refresh code is called in the callback event of successful uninstallation. At this point, the SW service can be uninstalled from the client without perception.

[0069] The method embodiments provided in the above embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on an electronic device as an example, Figure 3 1 is a hardware structure diagram of an electronic device of a browser refresh method provided by the present application. Figure 3 As shown, the electronic device 10 may include one or more (only one is shown in the figure) processors 02 (the processor 02 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 04 for storing data, and a transmission module 06 for communication functions. It can be understood by those skilled in the art that Figure 3 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 3 More or fewer components as shown, or with Figure 3 Different configurations are shown.

[0070] The memory 04 can be used to store software programs and modules of application software, such as program instructions / modules corresponding to the browser refresh method in the embodiment of the present application. The processor 02 executes various functional applications and data processing by running the software programs and modules stored in the memory 04, that is, the browser refresh method of the above-mentioned application is realized. The memory 04 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 04 may further include a memory remotely arranged relative to the processor 02, and these remote memories can be connected to the electronic device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0071] The transmission module 06 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the electronic device 10. In one example, the transmission module 06 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission module 06 can be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly.

[0072] At the software level, the browser refresh device can be as follows Figure 4 As shown, including:

[0073] Determination module 401, used to determine whether the middleman role SW between the server and the browser has been deployed in the target browser;

[0074] A setting module 402 is used to set not to cache index.html and listen to SW update events when it is determined that the SW has been deployed;

[0075] The trigger module 403 is used to immediately trigger the target browser to refresh when a SW update event is monitored.

[0076] In one embodiment, the browser refresh device may further include: a removal module, configured to remove the registration code and service-worker.js file of the SW after determining that the SW has been deployed.

[0077] In one embodiment, the browser refresh device may further include: a first adding module for adding code for uninstalling SW in index.html after determining that SW has been deployed; and a second adding module for adding code for refreshing the browser in the callback event of successfully uninstalling SW.

[0078] In one embodiment, the above-mentioned browser refresh device may also include: a receiving module, which is used to receive an uninstall request for SW after adding the code for uninstalling SW in index.html; a calling module, which is used to call and execute the code for uninstalling SW in index.html in response to the uninstall request; a confirmation module, which is used to confirm whether SW has been successfully uninstalled; and a refresh module, which is used to refresh the target browser by calling the code for refreshing the browser through a callback event when it is determined that the uninstallation has been successful.

[0079] The embodiments of the present application also provide a specific implementation of an electronic device capable of implementing all the steps in the browser refresh method in the above embodiments, wherein the electronic device specifically includes the following contents: a processor, a memory, a communication interface, and a bus; wherein the processor, the memory, and the communication interface communicate with each other through the bus; the processor is used to call a computer program in the memory, and when the processor executes the computer program, all the steps in the browser refresh method in the above embodiments are implemented. For example, when the processor executes the computer program, the following steps are implemented:

[0080] Step 1: Determine whether SW has been deployed in the target browser;

[0081] Step 2: If the SW has been deployed, set index.html not to be cached and listen to the SW update event;

[0082] Step 3: When a SW update event is monitored, immediately trigger a refresh of the target browser.

[0083] The present application provides a browser refresh method, which determines whether SW has been deployed in the target browser. If SW has been deployed in the target browser, it is set not to cache index.html and listen to SW update events; if SW update events are listened, it is immediately triggered to refresh the target browser. By setting not to cache index.html, it can be ensured that the updated version can be obtained by refreshing only once, and the latest version can be obtained without refreshing twice.

[0084] The embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps in the browser refresh method in the above embodiments. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all the steps in the browser refresh method in the above embodiments are implemented. For example, when the processor executes the computer program, the following steps are implemented:

[0085] Step 1: Determine whether SW has been deployed in the target browser;

[0086] Step 2: If the SW has been deployed, set index.html not to be cached and listen to the SW update event;

[0087] Step 3: When a SW update event is monitored, immediately trigger a refresh of the target browser.

[0088] The present application provides a browser refresh method, which determines whether SW has been deployed in the target browser. If SW has been deployed in the target browser, it is set not to cache index.html and listen to SW update events; if SW update events are listened, it is immediately triggered to refresh the target browser. By setting not to cache index.html, it can be ensured that the updated version can be obtained by refreshing only once, and the latest version can be obtained without refreshing twice.

[0089] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the hardware + program embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0090] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0091] Although the present application provides method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the actual device or client product is executed, it can be executed in the order of the method shown in the embodiments or the drawings or in parallel (for example, in a parallel processor or multi-threaded processing environment).

[0092] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a vehicle-mounted human-computer interaction device, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0093] Although the present specification embodiment provides the method operation steps as described in the embodiment or flow chart, more or less operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiment is only one way in the order of execution of many steps, and does not represent a unique execution order. When the device or terminal product in practice is executed, it can be executed in sequence or in parallel (such as a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment) according to the method shown in the embodiment or the accompanying drawings. The term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or equipment including a series of elements not only includes those elements, but also includes other elements not clearly listed, or also includes elements inherent to such process, method, product or equipment. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or equipment including the elements.

[0094] For the convenience of description, the above devices are described in various modules according to their functions. Of course, when implementing the embodiments of this specification, the functions of each module can be implemented in the same or more software and / or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0095] Those skilled in the art also know that, in addition to implementing the controller in a purely computer-readable program code, the controller can be made to implement the same function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered as a hardware component, and the devices for implementing various functions included therein can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules for implementing the method and structures within the hardware component.

[0096] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0097] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0098] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0099] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0100] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0101] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0102] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, the embodiments of this specification may take the form of complete hardware embodiments, complete software embodiments or embodiments combining software and hardware. Moreover, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0103] The present specification embodiments may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present specification embodiments may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0104] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. In the description of this specification, the description of the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of this specification. In this specification, the schematic representation of the above terms does not necessarily target the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, in the absence of contradiction, a person skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0105] The above is only an example of the embodiment of the present specification and is not intended to limit the embodiment of the present specification. For those skilled in the art, the embodiment of the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiment of the present specification shall be included in the scope of the claims of the embodiment of the present specification.

Claims

1. A browser refresh method, It is characterized in that The method comprises: Determine whether the target browser has deployed the middleman SW between the server and the browser; If SW has been deployed, set index.html not to be cached and listen for SW update events; When a SW update event is monitored, the target browser is immediately triggered to refresh.

2. The method according to claim 1, It is characterized in that After confirming that SW has been deployed, it also includes: Remove the SW registration code and service-worker.js file.

3. The method according to claim 1, It is characterized in that After confirming that SW has been deployed, it also includes: Add the code to uninstall SW in index.html; Add the code to refresh the browser in the callback event of successfully uninstalling SW.

4. The method according to claim 3, It is characterized in that After adding the code to uninstall SW in index.html, it also includes: Receive an uninstall request for SW; In response to the uninstallation request, calling and executing the uninstallation SW code in index.html; Confirm whether SW has been successfully uninstalled; When it is determined that the uninstallation is successful, the target browser is refreshed by calling the browser refresh code through the callback event.

5. A browser refresh device, It is characterized in that include: A determination module, used to determine whether a middleman role SW between the server and the browser has been deployed in the target browser; The setting module is used to set index.html not to be cached and listen to SW update events when SW is determined to be deployed; The trigger module is used to immediately trigger the refresh of the target browser when a SW update event is monitored.

6. The device according to claim 5, It is characterized in that Also includes: The removal module is used to remove the registration code and service-worker.js file of the SW after confirming that the SW has been deployed.

7. The device according to claim 5, It is characterized in that Also includes: The first adding module is used to add the code for uninstalling the SW in index.html after determining that the SW has been deployed; The second adding module is used to add the code of refreshing the browser in the callback event of successfully uninstalling the SW.

8. The device according to claim 7, It is characterized in that Also includes: The receiving module is used to receive the uninstallation request for SW after adding the code for uninstalling SW in index.html; A calling module, used for calling and executing the code of the uninstall SW in index.html in response to the uninstall request; Confirmation module, used to confirm whether SW has been successfully uninstalled; The refresh module is used to refresh the target browser by calling the code for refreshing the browser through a callback event when it is determined that the uninstallation has been successful.

9. An electronic device, comprising a processor and a memory for storing instructions executable by the processor, wherein when the processor executes the instructions, the steps of the following method are implemented: Determine whether SW has been deployed in the target browser; If SW has been deployed, set index.html not to be cached and listen for SW update events; When a SW update event is monitored, the target browser is immediately triggered to refresh.

10. A computer-readable storage medium having computer instructions stored thereon, wherein the instructions, when executed, implement the steps of the following method: Determine whether SW has been deployed in the target browser; If SW has been deployed, set index.html not to be cached and listen for SW update events; When a SW update event is monitored, the target browser is immediately triggered to refresh.

Citation Information

Patent Citations

  • PWA item detection method, computer readable storage medium and terminal device

    CN109324822A

  • Information processor, control method of information processor, and program

    JP2020095568A