Webpage loading method and device, electronic equipment and medium
Patent Information
- Application Number
- CN202211197162.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-29
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2042-09-29
AI Technical Summary
即使新旧两个版本之间差异较小,也会导致大量的页面加载时间和不必要的数据成本
[0015]本申请的第七方面公开了一种计算机程序产品,包括计算机程序,所述计算机程序被处理器执行时实现如本申请第一、二方面的方法。
Smart Images

Figure CN115408633B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a webpage loading method, apparatus, electronic device, and medium. Background Technology
[0002] A single-page application (SPA) is an application with only one web page, typically containing a single large JavaScript file. The JavaScript code changes frequently with application updates, and the server always retransmits the entire JavaScript code after an update. Even minor differences between the old and new versions can lead to significant page load times and unnecessary data costs. Summary of the Invention
[0003] The main objective of this application is to provide a webpage loading method, apparatus, electronic device, and medium to reduce data costs and page loading time.
[0004] The first aspect of this application discloses a webpage loading method for a user device. The method includes: initiating a webpage loading request to a server, the loading request including a version number of a cached webpage; when the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage on the server: receiving incremental data from the server, the incremental data being a distinguishing code fragment calculated by the server using a Zsync algorithm based on the data of the cached webpage and the data of the latest version of the webpage; concatenating the data of the cached webpage and the incremental data; and loading and displaying the concatenated webpage.
[0005] In one possible implementation of the first aspect described above, the Zsync algorithm includes calculating a block checksum for historical versions of web page data in the server and calculating a scroll checksum for the latest version of web page data in the server.
[0006] In one possible implementation of the first aspect above, the cached webpage is loaded when the version number of the cached webpage matches the version number of the latest version of the webpage on the server.
[0007] In one possible implementation of the first aspect described above, the method further includes updating the cached webpage data based on the incremental data.
[0008] A second aspect of this application discloses a webpage loading method for a server, the method comprising: receiving a webpage loading request from a user device, the loading request including a version number of a cached webpage; when the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage on the server: comparing the data of the cached webpage with the data of the latest version of the webpage on the server using a Zsync algorithm; calculating a difference code fragment between the data of the cached webpage and the data of the latest version of the webpage; and sending the difference code fragment as incremental data to the user device.
[0009] In one possible implementation of the second aspect above, comparing the version number of the cached webpage with the version number of the latest version of the webpage in the server using the Zsync algorithm includes calculating a block checksum for the historical version of the webpage data in the server and calculating a scroll checksum for the latest version of the webpage data in the server.
[0010] In one possible implementation of the second aspect above, when the version information of the cached file is consistent with the version information of the latest version file, it is detected whether the full file has been updated; when the full file has been updated, the full file is sent to the front end; when the full file has not been updated, a 304 status code is returned.
[0011] A third aspect of this application discloses a webpage loading apparatus, comprising: a first sending module for initiating a webpage loading request to a server, the loading request including a version number of a cached webpage; a first receiving module for receiving incremental data from the server when the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage on the server, the incremental data being a distinguishing code fragment calculated by the server using a Zsync algorithm based on the data of the cached webpage and the data of the latest version of the webpage; a generating module for concatenating the data of the cached webpage and the incremental data; and a loading module for displaying the concatenated webpage.
[0012] A fourth aspect of this application discloses a webpage loading apparatus, the apparatus comprising: a second receiving module for receiving a webpage loading request from a user device, the loading request including a version number of a cached webpage; a calculation module for, when the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage on the server: comparing the data of the cached webpage with the data of the latest version of the webpage on the server using a Zsync algorithm, and calculating a difference code fragment between the data of the cached webpage and the data of the latest version of the webpage; and a second sending module for sending the difference code fragment as incremental data to the user device.
[0013] The fifth aspect of this application discloses an electronic device including a memory storing computer-executable instructions and a processor; when the instructions are executed by the processor, the device performs the methods of the first and second aspects of this application.
[0014] The sixth aspect of this application discloses a computer-readable storage medium storing one or more computer programs, which are executed by one or more processors to perform the methods of the first and second aspects of this application.
[0015] The seventh aspect of this application discloses a computer program product, including a computer program that, when executed by a processor, implements the methods of the first and second aspects of this application.
[0016] This application discloses a webpage loading method, apparatus, electronic device, medium, and computer program product, providing a webpage loading optimization framework based on an incremental synchronization algorithm: Web-Zsync. This framework uses incremental data transmission. After calculating the incremental data during the version iteration process on the server side, it transmits the incremental data to the client, where it is merged with the old cached data. This not only reduces page load time but also lowers mobile data costs. Furthermore, it supports not only single-page applications but is also compatible with traditional web applications. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the present invention, the accompanying drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are merely some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without any creative effort.
[0018] Figure 1 This is a diagram illustrating the upgrade of a single-page application in related technologies.
[0019] Figure 2 This is a flowchart illustrating a webpage loading method 200 for a user device according to an embodiment of this application;
[0020] Figure 3 This is a schematic flowchart of a webpage loading method 300 for a server according to an embodiment of this application;
[0021] Figure 4 This is an interactive schematic diagram of a webpage loading method according to an embodiment of this application;
[0022] Figure 5a This is a schematic diagram of an incremental data calculation method according to an embodiment of this application;
[0023] Figure 5b This is a schematic diagram of the latest version of web page data, as indicated in one embodiment of this application;
[0024] Figure 6 This is a schematic flowchart of a webpage loading method according to an embodiment of this application;
[0025] Figure 7 This is a schematic diagram of a webpage loading device 700 provided in one embodiment of this application;
[0026] Figure 8 This is a schematic diagram of a webpage loading device 800 provided in one embodiment of this application;
[0027] Figure 9 This is a schematic diagram of the structure of an electronic device 900 according to an embodiment of this application. Detailed Implementation
[0028] The present application will be further described below with reference to specific embodiments and accompanying drawings. It is understood that the illustrative embodiments of this disclosure include, but are not limited to, webpage loading methods, apparatuses, electronic devices, media, and computer program products. The specific embodiments described herein are merely for explaining the present application and not for limiting it. Furthermore, for ease of description, the accompanying drawings show only the parts relevant to the present application, and not all of the structures or processes.
[0029] The following specific embodiments illustrate the implementation of this application. Those skilled in the art can easily understand other advantages and effects of this application from the content disclosed in this specification. Although the description of this application will be presented in conjunction with preferred embodiments, this does not mean that the features of this invention are limited to this embodiment. On the contrary, the purpose of describing the invention in conjunction with embodiments is to cover other options or modifications that may be derived based on the claims of this application. To provide a thorough understanding of this application, many specific details will be included in the following description. This application may also be implemented without using these details. Furthermore, to avoid confusion or obscuring the focus of this application, some specific details will be omitted in the description. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of this application can be combined with each other.
[0030] Furthermore, the various operations will be described as multiple discrete operations in a manner most conducive to understanding the illustrative embodiments; however, the order of description should not be construed as implying that these operations must depend on the order. In particular, these operations do not need to be performed in the order presented.
[0031] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0032] Unlike traditional web applications, single-page applications (SPAs) consist of only a single web page, typically containing a single JavaScript file. When the application needs to load another page, the JavaScript code dynamically updates the page without refreshing it, thus improving the smoothness of the web application. This allows mobile users to experience a user experience similar to native applications. This JavaScript file is used to control functionality and the application's workflow, and is usually quite large.
[0033] Single-page applications (SPAs) are characterized by frequent updates. In related technologies, the process of upgrading SPAs (see...) Figure 1 )include:
[0034] 101. When a user logs into a single-page application, the user's device sends the version number of the single-page application to the server.
[0035] 102. The server obtains the latest version number of the single-page application and compares it with the version number sent by the front end.
[0036] 103. When the server finds that the two are different, it retrieves all the code of the single-page application corresponding to the latest version number and sends it to the front end.
[0037] 104. The user device upgrades the single-page application based on all the received codes.
[0038] For JavaScript files, even if only a small portion of the code is modified, the entire JavaScript file will be retransmitted if the user requests the website again. Related webpage upgrade methods cause unnecessary data transfer, thus increasing data traffic overhead and page load time.
[0039] To address the aforementioned problems, one embodiment of this application provides a webpage loading method 200 for a user device, see [link to relevant documentation]. Figure 2 .
[0040] In S210, a webpage loading request is sent to the server, which includes the version number of the cached webpage.
[0041] When a user logs into a single-page application (SPA) on their device, the system first checks if a page cache exists on the device. If no page cache exists, a request is sent to the server to retrieve the complete code of the SPA. In other words, when a user first accesses a SPA's page through their device, all resource data for the SPA can be obtained from the server. This resource data includes the SPA's version number, which the user device can store.
[0042] User devices include browser clients or single-page application clients. Each time a user logs into the interface of a single-page application through their device, method 200 can be used to determine whether a new version of the single-page application has been released.
[0043] In S220, when the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage on the server, incremental data is received from the server. The incremental data is a code fragment that the server calculates using the Zsync algorithm based on the data of the cached webpage and the data of the latest version of the webpage.
[0044] The Zsync algorithm is a variant of the Rsync algorithm. The Rsync incremental transfer algorithm is a sliding block difference detection algorithm. Taking the detection of differences between files A and B as an example, A is first divided into several blocks of a fixed length L, and a weak digest and a strong digest are generated for each block. Then, for B, starting from the first byte, a sliding window of length L is used to traverse the entire file, calculating the weak and strong digests for each window block and comparing them with the digest values in A. Blocks with the same weak and strong digests are considered identical data blocks; otherwise, they are considered difference blocks.
[0045] The Zsync algorithm modifies the Rsync incremental transfer algorithm and is based on the HTTP protocol, making it suitable for wide area network applications. Zsync is suitable for scenarios involving large files that change relatively infrequently, with a server acting as the distribution point and a large number of clients downloading the file. This algorithm is primarily used when a file on the server needs to be synchronized across multiple clients after an update. The Zsync algorithm allows the publisher (server) to support incremental downloads from a large number of clients with only a single signature calculation, alleviating server load.
[0046] The typical steps in the Zsync algorithm are: 1) The publisher creates a new system installation ISO image and generates a corresponding sign file, both of which are provided as HTTP download addresses; 2) If the client does not have an older version image, it downloads the entire ISO file; if the client has an older version image, it downloads the sign file, calculates the delta file, and merges it into the new version image. During the merging process, identical blocks are read from the local older version, while different blocks are downloaded from the server using HTTP Range.
[0047] In this application, if the Zsync algorithm is used directly on the client (i.e., the user's device), the computation on the client side would result in significant time consumption due to the client's performance limitations, thus increasing page load time. This application, referencing the Zsync algorithm, uses the server side, rather than the client side, to calculate the differentiable code fragments based on the latest version of the webpage data and the webpage data cached on the client, thereby reducing page load time.
[0048] In S230, the cached webpage data and incremental data are concatenated.
[0049] After receiving the incremental data, the user device merges the incremental data with the existing cached data to obtain the updated webpage data.
[0050] In S240, the concatenated webpage is loaded and displayed.
[0051] After retrieving the updated webpage data, load the updated webpage data and display the updated webpage.
[0052] Figure 3 This application provides an embodiment of a webpage loading method 300 for a server. Method 300 includes the following steps.
[0053] In S310, a loading request for a webpage from a user device is received, and the loading request includes the version number of the cached webpage.
[0054] In S320, when the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage on the server, the Zsync algorithm is used to compare the data of the cached webpage with the data of the latest version of the webpage.
[0055] Before a client requests the latest file, the server can split the latest version of the webpage data and obtain a list of checksums (hash values) for each block. The hash list only needs to be calculated once, and multiple subsequent clients can use the same hash list file.
[0056] In S330, there is a code snippet that calculates the difference between the data of the cached webpage and the data of the latest version of the webpage.
[0057] In S340, the distinguishing code snippet is sent to the user equipment as incremental data.
[0058] To better illustrate Figure 2-3 The webpage loading method in the middle, Figure 4 An interactive diagram of a webpage loading method according to one embodiment of this application is shown.
[0059] In a 401 error, the user equipment initiates a request to the server.
[0060] The request initiated by the user device to the server includes the version number of the webpage cached on the user device.
[0061] In a 402 error, incremental data is calculated when version numbers are inconsistent.
[0062] When the version number of a cached webpage differs from the latest version number of the webpage on the server, the cached webpage on the user's device needs to be updated. The server uses the Zsync algorithm to compare the data of the cached webpage with the data of the latest version of the webpage on the server. The server retains data for all historical versions of the webpage; after determining the version number of the requested webpage, it can directly retrieve the data of the corresponding version and compare it with the data of the latest version of the webpage.
[0063] The difference between the cached webpage data (data for the corresponding version of the webpage) and the latest version of the webpage data is calculated using code snippets as incremental data.
[0064] In a 403 error, send a distinguishing code.
[0065] The server sends the calculated difference code between the two versions of the webpage to the user's device as incremental data.
[0066] In the 404 error, load the updated webpage.
[0067] After receiving incremental data, the user device concatenates the incremental data with the data from the cached webpage and loads the updated webpage data for display.
[0068] Methods 200 and 300 of this application provide a webpage loading optimization framework, Web-Zsync, based on an incremental synchronization algorithm. This framework uses incremental data transmission. After calculating the incremental data for the version iteration process on the server side, it transmits the incremental data to the client, where it is merged with the old cached data. This method not only reduces page load time but also lowers mobile data costs. Furthermore, it ensures smooth page loading even in poor network conditions. Web-Zsync is highly practical, supporting both single-page applications and traditional web applications.
[0069] Furthermore, the Web-Zsync framework is simple and easy to use; users do not need to install any specific browser or modify the framework's source code. It runs on most popular browsers, such as Chrome, Safari, and Firefox. The framework also provides developers with various options, such as the caching method used, the interaction protocol, the file chunk size, the folder addresses to be monitored, and the location of resource files.
[0070] The Web-Zsync framework also adapts to existing caching strategies and CDN optimization strategies. Because existing caching strategies and CDN optimization solutions can greatly improve page loading speed, Web-Zsync is compatible with caching strategies and CDN to achieve better performance. If a file is not updated, Web-Zsync will automatically use the cached file, which can minimize the amount of data transferred and is compatible with traditional web applications and single-page applications.
[0071] In some implementations, block checksums are calculated for historical versions of web page data on the server, and scroll checksums are calculated for the latest versions of web page data on the server.
[0072] One server serves multiple clients, each caching different historical versions of webpage data. In incremental data calculation, if the latest version of the webpage data is used as the baseline, it's necessary to scroll through each window block starting from the first byte of each historical version until the entire file is traversed. When the server receives requests from multiple clients, it needs to perform a scrolling checksum on multiple historical versions of the webpage data, leading to high computational costs.
[0073] Figure 5a An incremental data calculation method according to an embodiment of this application is shown.
[0074] After receiving a request from one or more user devices, the server divides the stored historical versions of web pages into several blocks of fixed length, with the last block potentially shorter than the fixed length. A checksum is calculated for each block and stored in a hash table.
[0075] For the latest version of the webpage data, the sliding window starts from the first byte and uses the fixed length mentioned above (see [link]). Figure 5a The scroll checksum is calculated within the shaded box in the hash table. If the calculated scroll checksum is found in the hash table, the page is shifted one block forward. If not found, the page is shifted one byte forward, and the scroll checksum in the new sliding window is calculated. This process continues until the entire latest version of the webpage data has been traversed.
[0076] Figure 5b It shows according to Figure 5a The calculation method yields a schematic diagram of the latest version of the webpage data with annotations.
[0077] The white boxes represent the distinguishing codes between historical and latest versions, and each white box can be of variable length. These white boxes together form the incremental data. The diagonal boxes represent data already present in historical versions of the webpage. The order of each diagonal box does not necessarily match the order of its corresponding box (i.e., existing block) in the historical version, and the number of diagonal boxes can be less than the number of corresponding boxes in the historical version.
[0078] After calculating the incremental data, the server can display the actual content within the white box and... Figure 5b The block number within the diagonal box is sent to the client. The client will then... Figure 5b The array order is used to concatenate incremental data and historical versions of webpage data to obtain updated webpage data.
[0079] Figure 5a The method of performing block checksums on historical versions of webpage data and rolling checksums on the latest versions of webpage data can save computational costs. Furthermore, to save computation time, the server can store the block checksum for each historical version.
[0080] The server can also Figure 5b The latest version of the webpage data marked in the annotation is saved. When other clients send requests with the same historical version, it can be directly used. Figure 5b As a result, incremental data will be sent to the other client.
[0081] After including WebZsync-Client.js in your front-end page and performing simple configuration, deploy the page to the server and enable WebZsync-Server. Regular users can then retrieve the page using incremental transfer. If a user visits the page for the first time, Web-Zsync will retrieve the full file and cache it. If the user subsequently refreshes the page and the file hasn't been updated, Web-Zsync will directly use the cached file; if the file has been updated, Web-Zsync will retrieve the incremental file and render it in the browser. See details... Figure 6 .
[0082] Figure 6 A flowchart of a webpage loading method according to an embodiment of this application is shown.
[0083] In S601, users log in to the client to access the page.
[0084] In S602, the client detects page caching.
[0085] If this is the first time accessing the page, the process proceeds to S603, where the client sends a request for all data to the server. Subsequently, after the client obtains all the data in S604, the process proceeds to S610, where the client loads the webpage data.
[0086] If this is not the first time accessing the page, and the client has a page cache, then the process enters S605, where the client sends a request to the server.
[0087] In S606, the server detects the difference between the webpage version sent by the client and the latest webpage version on the server.
[0088] If the two versions differ, then proceed to S608, where the server returns incremental data.
[0089] If the two versions are identical, the process proceeds to S607, where the server checks if all data has been updated. If updated, the process proceeds to S604; otherwise, it proceeds to S613, where the server sends a 304 status code to the client, indicating that the requested content was not downloaded from the server but was read from the local cache. Then, the process proceeds to S614, where the client executes the cache.
[0090] S606-S607 guarantees a certain degree of fault tolerance. For example, if the full resource data has been updated but the incremental file is still being calculated, and the user refreshes the page, WebZsync will automatically retrieve the new full data if it cannot obtain the incremental data.
[0091] After S608, in S609, the client concatenates cached and incremental data. Then, in S610, the client loads webpage data, loads the concatenated data, and displays it.
[0092] In S611, the client determines whether the cache needs to be updated. If so, it proceeds to S612 to perform the update; otherwise, the process ends directly.
[0093] Figure 7 This is a schematic diagram of a webpage loading device 700 provided in one embodiment of this application. The device 700 includes,
[0094] The first sending module 710 is used to send a webpage loading request to the server, and the loading request includes the version number of the cached webpage.
[0095] The first receiving module 720 is used to receive incremental data from the server when the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage in the server. The incremental data is a code fragment that the server calculates based on the data of the cached webpage and the data of the latest version of the webpage using the Zsync algorithm.
[0096] The generation module 730 is used to combine cached webpage data and incremental data;
[0097] Load module 740 to display the assembled webpage.
[0098] Figure 8 This is a schematic diagram of a webpage loading device 800 provided in one embodiment of this application. The device 800 includes,
[0099] The second receiving module 810 is used to receive a webpage loading request from a user device, the loading request including the version number of the cached webpage;
[0100] The calculation module 820 is used to compare the data of the cached webpage with the data of the latest version of the webpage on the server using the Zsync algorithm when the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage on the server, and calculate the difference between the data of the cached webpage and the data of the latest version of the webpage.
[0101] The second sending module 830 is used to send the difference code fragment as incremental data to the user equipment.
[0102] Now for reference Figure 9 The diagram shown is a block diagram of an electronic device 900 according to an embodiment of the present application. The electronic device 900 may include one or more processors 902, system control logic 908 connected to at least one of the processors 902, system memory 904 connected to the system control logic 908, non-volatile memory (NVM) 906 connected to the system control logic 908, and network interface 910 connected to the system control logic 908.
[0103] Processor 902 may include one or more single-core or multi-core processors. Processor 902 may include any combination of general-purpose processors and special-purpose processors (e.g., graphics processors, application processors, baseband processors, etc.). In embodiments herein, processor 902 may be configured to perform operations according to... Figure 2-8 One or more embodiments of the various embodiments shown.
[0104] In some embodiments, system control logic 908 may include any suitable interface controller to provide any suitable interface to at least one of the processors 902 and / or any suitable device or component communicating with system control logic 908.
[0105] In some embodiments, system control logic 908 may include one or more memory controllers to provide an interface to system memory 904. System memory 904 may be used to load and store data and / or instructions. In some embodiments, memory 904 of device 900 may include any suitable volatile memory, such as suitable dynamic random access memory (DRAM).
[0106] NVM / Memory 906 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, NVM / Memory 906 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device, such as at least one of HDD (Hard Disk Drive), CD (Compact Disc) drive, and DVD (Digital Versatile Disc) drive.
[0107] NVM / Storage 906 may include a portion of storage resources mounted on the device 900, or it may be accessible by the device but is not necessarily part of the device. For example, NVM / Storage 906 may be accessed over a network via network interface 910.
[0108] Specifically, system memory 904 and NVM / memory 906 may each include a temporary copy and a permanent copy of instruction 920. Instruction 920 may include, when executed by at least one of processors 902, causing device 900 to perform, as Figure 2-3 The instructions for the method shown. In some embodiments, the instructions 920, hardware, firmware and / or their software components may additionally / alternatively be located in the system control logic 908, the network interface 910 and / or the processor 902.
[0109] Network interface 910 may include a transceiver for providing a radio interface to device 900, thereby enabling communication with any other suitable device (such as a front-end module, antenna, etc.) via one or more networks. In some embodiments, network interface 910 may be integrated into other components of device 900. For example, network interface 910 may be integrated into at least one of processor 902, system memory 904, NVM / memory 906, and firmware device (not shown) with instructions that, when at least one of processor 902 executes the instructions, device 900 implements... Figure 2-8 One or more embodiments of the various embodiments shown.
[0110] The network interface 910 may further include any suitable hardware and / or firmware to provide a multiple-input multiple-output radio interface. For example, the network interface 910 may be a network adapter, a wireless network adapter, a telephone modem, and / or a wireless modem.
[0111] In one embodiment, at least one of the processors 902 may be packaged together with the logic of one or more controllers for system control logic 908 to form a system-in-package (SiP). In another embodiment, at least one of the processors 902 may be integrated on the same die with the logic of one or more controllers for system control logic 908 to form a system-on-a-chip (SoC).
[0112] Device 900 may further include: input / output (I / O) device 912. I / O device 912 may include a user interface that enables a user to interact with device 900; the design of the peripheral component interface enables peripheral components to also interact with device 900.
[0113] In some embodiments, the user interface may include, but is not limited to, a display (e.g., a liquid crystal display, a touch screen display, etc.), a speaker, a microphone, one or more cameras (e.g., a still image camera and / or a video camera), a flashlight (e.g., a light-emitting diode flash), and a keyboard.
[0114] In some embodiments, the peripheral component interface may include, but is not limited to, a non-volatile memory port, an audio jack, and a power interface.
[0115] All methods and implementations of this application can be implemented in the form of software, magnetic files, firmware, etc.
[0116] Program code can be applied to input instructions to perform the functions described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application-specific integrated circuit (ASIC), or a microprocessor.
[0117] The program code can be implemented using a high-level procedural language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used when needed. In fact, the mechanisms described in this paper are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.
[0118] One or more aspects of at least one embodiment can be implemented by representational instructions stored on a computer-readable storage medium, the instructions representing various logics in a processor, which, when read by a machine, cause the machine to create logic for performing the techniques described herein. These representations, referred to as “IP cores,” can be stored on a tangible computer-readable storage medium and provided to multiple customers or production facilities for loading into manufacturing machines that actually manufacture the logic or processor.
[0119] One embodiment of this application discloses a computer-readable medium storing one or more programs, which can be executed by one or more processors to implement... Figure 2-6 The method.
[0120] One embodiment of this application discloses a computer program product, including a computer program, which is implemented when executed by a processor. Figure 2-6 The method.
[0121] Unless the context otherwise specifies, the terms “contains,” “has,” and “includes” are synonyms. The phrase “A / B” means “A or B.” The phrase “A and / or B” means “(A and B) or (A or B).”
[0122] As used herein, the terms “module” or “unit” may refer to, be, or include: application-specific integrated circuits (ASICs), electronic circuits, (shared, dedicated, or group) processors and / or memories that execute one or more software or firmware programs, combinational logic circuits, and / or other suitable components that provide the described functionality.
[0123] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored thereon on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed via a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism, but not limited to, for storing or transmitting information in a machine-readable (e.g., computer-readable) form, such as floppy disks, optical disks, CD-ROMs, magneto-optical disks, read-only memory (ROM), random access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable storage for transmitting information over the Internet via electrical, optical, acoustic, or other forms of propagation signals (e.g., carrier waves, infrared signals, digital signals, etc.). Therefore, machine-readable media include any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.
[0124] In the accompanying drawings, certain structural or methodological features are shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be necessary. In some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. Furthermore, the inclusion of structural or methodological features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may be omitted or may be combined with other features.
[0125] It should be understood that although terms such as "first," "second," etc., may be used herein to describe various units or data, these units or data should not be limited by these terms. These terms are used merely to distinguish one feature from another. For example, without departing from the scope of the exemplary embodiments, a first feature may be referred to as a second feature, and similarly, a second feature may be referred to as a first feature.
[0126] It should be noted that in this specification, similar reference numerals and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
Claims
1. A single-page loading method for a user device, characterized in that, The method includes: Send a request to the server to load a webpage, the request including the version number of the cached webpage; When the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage on the server: The system receives incremental data from the server. The incremental data is a distinguishing code segment calculated by the server using the Zsync algorithm based on the difference between the JavaScript code of the cached webpage and the JavaScript code of the latest version of the webpage. The Zsync algorithm includes the server dividing the JavaScript code of one or more historical versions of the webpage stored in the server into several blocks of fixed length, calculating the checksum of each block and storing it in a hash table, and calculating the scroll checksum of the JavaScript code of the latest version of the webpage in the server. Combine the data from the cached webpage with the incremental data; Load and display the concatenated webpage; Specifically, when the version number of the cached webpage is the same as the version number of the latest version of the webpage, it is checked whether the full file has been updated; When the full file is updated, the full file is sent to the user equipment; If the full file has not been updated, a 304 status code is returned.
2. The method according to claim 1, characterized in that, The cached webpage is loaded when the version number of the cached webpage matches the version number of the latest version of the webpage on the server.
3. The method according to claim 1, characterized in that, The method further includes updating the cached webpage data based on the incremental data.
4. A single-page loading method for a server, characterized in that, The method includes: Receive a webpage loading request from a user device, the loading request including the version number of the cached webpage; When the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage on the server: The Zsync algorithm is used to compare the JavaScript code of the cached webpage with the JavaScript code of the latest version of the webpage on the server; The Zsync algorithm calculates the difference between the JavaScript code of the cached webpage and the JavaScript code of the latest version of the webpage. The Zsync algorithm includes the server dividing the JavaScript code of one or more historical versions of the webpage stored in the server into several blocks of fixed length, calculating the block checksum for each block and storing it in a hash table, and calculating the scroll checksum for the JavaScript code of the latest version of the webpage in the server. The distinguishing code fragment is sent as incremental data to the user equipment; Specifically, when the version number of the cached webpage is the same as the version number of the latest version of the webpage, it is checked whether the full file has been updated; When the full file is updated, the full file is sent to the user equipment; If the full file has not been updated, a 304 status code is returned.
5. A single-page loading device, characterized in that, The device includes, The first sending module is used to send a webpage loading request to the server, wherein the loading request includes the version number of the cached webpage; The first receiving module is configured to receive incremental data from the server when the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage in the server. The incremental data is a distinguishing code segment calculated by the server using the Zsync algorithm based on the code segment differences between the JavaScript code of the cached webpage and the JavaScript code of the latest version of the webpage. The Zsync algorithm includes the server dividing the JavaScript code of one or more historical versions of the webpage stored in the server into several blocks of fixed length, calculating the checksum of each block, storing it in a hash table, and calculating a scroll checksum for the JavaScript code of the latest version of the webpage in the server. The first receiving module is further configured to receive a response from the server when the version number of the cached webpage is consistent with the version number of the latest version of the webpage, wherein the response is a full file or a 304 status code; A generation module is used to combine the data of the cached webpage with the incremental data; Load the module used to combine and display the webpage.
6. A single-page loading device, characterized in that, The device includes, The second receiving module is used to receive a webpage loading request from a user device, wherein the loading request includes the version number of the cached webpage; The calculation module is used to: compare the JavaScript code of the cached webpage with the JavaScript code of the latest version of the webpage on the server using the Zsync algorithm when the version number of the cached webpage is inconsistent with the version number of the latest version of the webpage on the server, and calculate the difference code segment between the JavaScript code of the cached webpage and the JavaScript code of the latest version of the webpage. The Zsync algorithm includes the server dividing the JavaScript code of one or more historical versions of the webpage stored in the server into several blocks of fixed length, calculating the checksum of each block, storing it in a hash table, and calculating the scroll checksum of the JavaScript code of the latest version of the webpage on the server. The second sending module is used to send the distinguishing code fragment as incremental data to the user equipment; The calculation module is also used to detect whether the full file has been updated when the version number of the cached webpage is the same as the version number of the latest version of the webpage. The second sending module is further configured to send the full file to the user equipment when the full file is updated; If the full file has not been updated, a 304 status code is returned.
7. An electronic device, characterized in that, The device includes a memory storing computer-executable instructions and a processor; when the instructions are executed by the processor, the device performs the method according to any one of claims 1 to 4.
8. A computer-readable medium, characterized in that, The medium stores one or more programs, which can be executed by one or more processors to implement the method of any one of claims 1 to 4.
9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
H5 page loading method and device, electronic equipment and readable storage medium
CN109710870A