Webpage static resource loading method and device, equipment and storage medium
By downloading and storing the static resource compression package of H5 pages on the client, local resources are directly loaded to reduce the loading time of H5 pages, which solves the problems of slow loading speed and network impacts, and improves the user experience.
Patent Information
- Application Number
- CN202411689986.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2024-12-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In mobile applications, the static resource loading speed of H5 pages is slow and is affected by network conditions, affecting the user experience.
When the client application is started, the compressed package and its basic information file are downloaded and stored, and the resource path requested by the page determines whether it exists in the local storage. If it exists, the local resources will be loaded directly to bypass HTTP requests.
Reduces the loading time of H5 pages, improves the user experience, and avoids loading delays caused by network latency and instability through local resource loading.
Smart Images

Figure CN119179822A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a method, device, equipment and storage medium for loading static resources of a web page. Background Art
[0002] In the field of mobile application development, the pages visited by users are mainly divided into two technical implementation forms: client native pages and front-end H5 pages. For client native pages, the update of their page content needs to rely on the iteration of the application version, which not only requires a long review cycle of the application store, but also has the risk of being rejected. At the same time, it also depends on the user to actively download and install the new version. These factors make it impossible to update the content of the native page in time.
[0003] Although converting native pages to front-end H5 pages can solve the version dependency problem and achieve timely content updates, H5 pages need to load HTML, images, JavaScript, CSS and other resource files through HTTP requests, so their loading speed is slower than that of native pages that can directly read local static resources, and the page rendering effect is also easily affected by network conditions, which seriously affects the user experience of mobile applications.
[0004] In view of this, the solution of the present invention is proposed. Summary of the invention
[0005] The present invention discloses a method, device, equipment and storage medium for loading static resources of a webpage, aiming to reduce the loading time of an H5 page to improve the user experience.
[0006] A first aspect of the present invention provides a method for loading static resources of a web page, comprising: When the client application is started, it downloads the compressed package and its basic information files from the remote server through a network request and stores them in the local storage, wherein the compressed package is generated by the front end by packaging the static resources required by the client's H5 project based on the plug-in; When a user accesses a page containing static resources, it is determined whether the resource requested by the page exists in the local storage according to the resource path of the page request. If so, the local resource is directly loaded, bypassing the HTTP request.
[0007] Preferably, when the application on the client is started, the compressed package and its basic information file are downloaded from the remote server through a network request, and stored in the local storage, specifically: When the application starts, it queries the remote server to obtain the configuration list of all offline packages, and performs corresponding operations based on the queried configuration to detect local resources; When the backend management end edits the offline package configuration, the server end actively notifies the client end through IM events to update the configuration and update and download local resources; According to the preset trigger scenario configuration, the download logic of the offline package resources is triggered when the user enters the specified page, and the download logic is distributed to the required services; wherein, the download logic includes: comparing the version number in the offline package configuration and the version number of the local resource, when the local version is not equal to the version in the configuration and the mobile phone storage space is sufficient, downloading a new resource package according to the resource package address; splitting the resource file into the .download file being downloaded, the .zip file that has been downloaded, the temp folder being decompressed, and the cur folder of complete resources that can be loaded.
[0008] Preferably, when the application is started, it queries the remote server to obtain the configuration list of all offline packages, and performs corresponding operations based on the queried configuration to detect local resources, specifically: When the offline package function switch in the configuration is turned off, no offline package related logic processing is performed; According to the version number information in the offline package configuration, delete the old versions and local resources that are not in the configuration list and have not been used for a long time, and control the timing and activation quantity of resource downloads according to the pre-download strategy, pre-download trigger scenario and activation quantity limit in the offline package configuration.
[0009] Preferably, the compressed package is generated by the front end by packaging the static resources of the H5 project based on the plug-in, specifically: Get project information, parse index.html in the project root directory, and use the content in the title tag as the offline package identifier; Generate the current offline package version number, query whether the version number is specified through the parameter through process.argv, if so, use the provided version number, if not, check whether the manifest.json in the main repository exists, if so, get the version field and add 1 as the version number, if not, build the first version number; The project information, offline package version number, generation time, generation project name, and generation environment information are packaged to generate a manifest.json file, and then packaged into a zip compressed package using archiver.
[0010] Preferably, the method further comprises: generating an md5 hash value of the zip compressed package through a crypto module, and writing the hash value into the outer manifest.json for subsequent package verification.
[0011] Preferably, when a user accesses a page containing static resources, it is determined whether the resource requested by the page exists in the local storage according to the resource path of the page request, and if so, the local resource is directly loaded, bypassing the HTTP request, and further comprising: Obtain the resource address through the resource request provided by WebView, and intercept the resource request to perform local resource loading processing; Obtaining a corresponding path value according to the resource address, and obtaining a corresponding offline package configuration based on the path value match; Determine whether the current page has reached the upper limit of the hit amount according to the configuration information of the offline package configuration, and if so, do not intercept and execute online resource loading; The resource address is converted through md5 encryption to obtain the directory name of the resource package of the current page, and is concatenated with the version number in the offline package configuration to form a complete path of the local resource. Check whether there is a cur folder under the path. If not, it is determined that the local resource does not exist and online resource loading is executed; When the page fails to load local resources and the current page configuration does not reach the activation limit, the offline package resources are downloaded and decompressed.
[0012] Preferably, the basic information file includes a unique identifier, a version number, a file type, and a checksum of the static resource.
[0013] A second aspect of the present invention provides a device for loading static resources of a web page, comprising: A compressed package acquisition unit, when the client application is started, downloads the static resource compressed package and its basic information file of the H5 project from the remote server through a network request, and stores the static resource compressed package and its basic information file in the local storage, wherein the compressed package is generated by the front end by packaging the static resources required by the client's H5 project based on the plug-in; The static resource loading unit is used to determine whether the resource requested by the page exists in the local storage according to the resource path of the page request when the user visits the page containing the static resource. If so, the local resource is directly loaded, bypassing the HTTP request.
[0014] A third aspect of the present invention provides a device for loading static resources of a web page, characterized in that it includes a memory and a processor, wherein a computer program is stored in the memory, and the computer program can be executed by the processor to implement a method for loading static resources of a web page as described in any one of the above items.
[0015] A fourth aspect of the present invention provides a computer-readable storage medium, characterized in that a computer program is stored therein, and the computer program can be executed by a processor of a device where the computer-readable storage medium is located to implement a method for loading static resources of a web page as described in any one of the above items.
[0016] Based on a method, device, equipment and storage medium for loading static resources of a web page provided by the present invention, when the application on the client is started, a compressed package and its basic information files are downloaded from a remote server through a network request, and stored in a local storage. Then, when a user accesses a page containing static resources, it is determined whether the resources requested by the page exist in the local storage according to the resource path of the page request. If so, the local resources are directly loaded, bypassing the HTTP request, thereby reducing the H5 page loading time and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 It is a flow chart of a method for loading static resources of a web page provided by the first aspect of the present invention; Figure 2 It is a module schematic diagram of a device for loading static resources of a web page provided in the second aspect of the present invention. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0019] In order to better understand the technical solution of the present invention, the embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0020] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0021] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.
[0022] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0023] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.
[0024] The "first\second" mentioned in the embodiments is only to distinguish similar objects, and does not represent a specific order for the objects. It is understandable that the "first\second" can be interchanged with the specific order or sequence where permitted. It should be understood that the objects distinguished by "first\second" can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than those illustrated or described herein.
[0025] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0026] The present invention discloses a method, device, equipment and storage medium for loading static resources of a webpage, aiming to reduce the loading time of an H5 page to improve the user experience.
[0027] See also Figure 1 In a first aspect, the present invention provides a method for loading static resources of a web page, which can be executed by a loading device for loading static resources of a web page (hereinafter referred to as a loading device), and in particular, is executed by one or more processors in the loading device to implement at least the following steps: S101, when the client application is started, a compressed package and its basic information files are downloaded from a remote server through a network request, and stored in a local storage, wherein the compressed package is generated by the front end by packaging the static resources required by the client's H5 project based on the plug-in; In this embodiment, the loading device may be a terminal with data processing capabilities such as a laptop computer, a desktop computer, a workstation, etc. The loading device may be installed with a corresponding operating system and application software, and the functions required by this embodiment are realized through the combination of the operating system and the application software.
[0028] It should be noted that, in this embodiment, the generation of the offline package first starts with the acquisition of project information. The loading device automatically extracts the content in the title tag by parsing the index.html file in the root directory of the project and uses it as the identification name of the offline package. This ensures the consistency of the generated offline package with the project identification, so that the source of the package can be quickly identified on the client later. Subsequently, in order to ensure that the version information of each offline package is accurate and unique, the loading device will try to obtain the version number through the process.argv command line parameter so that the user can directly specify the version when generating the offline package; if not specified, the loading device will automatically check whether the manifest.json file in the main repository of the project exists. If it exists, the version field therein will be read, and 1 will be added to the original version number as the new version number to ensure that the newly generated offline package has an incremental version identification. If the manifest.json file is not found, the loading device will generate the first version number for the project, thereby starting version control. After obtaining the complete project information and offline package version information, the loading device will integrate these data, including the project name, version number, generation time, project environment information, etc., into the manifest.json file. Ensure that the offline package can accurately determine the resource update requirements based on the version number when it is loaded on the client. At the same time, the loading device uses the archiver tool to package the manifest.json and static resources into a compressed package in zip format. The generated offline package not only contains the resource files of the project, but also integrates the resource version and environment information, which is convenient for verifying the integrity of resources on the client.
[0029] Furthermore, in this embodiment, when the client application is started, it will first send a request to the remote server to query and obtain the configuration list of all available offline packages. Based on the configuration data returned by the server, the client automatically detects the status of the locally stored resources to ensure that the local resources remain consistent with the server. When it is detected that the management end has edited and updated the offline package configuration, the client promptly receives the notification through the IM event, thereby automatically executing the configuration update and the re-download process of the local resources to ensure that the client always has the latest resource version. In addition, the client will also optimize the resource download strategy according to the preset trigger scenario configuration. When the user enters certain specified pages, the client will trigger the download logic of the offline package resources, flexibly assign the download operation to the specific business page, and avoid irrelevant pages consuming resources to download.
[0030] The download logic may include but is not limited to: the client compares the version number in the offline package configuration with the version number of the local resource. When it is detected that the local version is lower than the server configuration version and the device storage space is sufficient, the client automatically downloads the latest resource package according to the remote address of the resource package. During the download process, the resource files are reasonably divided into the .download file being downloaded, the .zip file after the download is completed, the temp folder generated during decompression, and the final loadable complete resource cur folder. File splitting not only provides clear status management during the download and decompression process, but also effectively reduces the risk of failure caused by incomplete files during resource loading.
[0031] Furthermore, in this embodiment, according to the offline package configuration returned by the server, the client will automatically detect the status of local resources and perform corresponding operations. For example, when it is detected that the offline package function switch is set to off in the configuration, the client will not perform any operations related to the offline package, avoiding unnecessary resource occupation and processing. In addition, the client accurately determines the update requirements of local resources through the version number information in the offline package configuration, and automatically deletes old version resources and resources that are not in the configuration list and have not been accessed for a long time, thereby effectively freeing up device storage space and reducing the burden of storage management.
[0032] At the same time, the client will control the download timing and activation quantity of resources according to the pre-download strategy, pre-download triggering scenario and activation quantity limit conditions in the offline package configuration. The pre-download strategy ensures that resources are obtained under appropriate conditions. For example, it can be limited to triggering downloads only in a WIFI environment or on a specific application page to reduce traffic consumption and improve resource loading efficiency. The activation quantity limit is used to control the download frequency and usage frequency of specific resource packages to ensure the reasonable allocation and use of resources. In this way, the client can automatically complete the update, optimization and efficient management of resources, thereby optimizing storage space and quickly loading resources without affecting the user experience.
[0033] In a possible implementation of the present invention, in order to ensure the integrity and security of the resource package, the MD5 hash value of the generated zip compressed package is calculated when the offline package is generated. The hash value, as the unique fingerprint of the file, can accurately identify the content of the compressed package, thereby providing an integrity verification mechanism. The generated MD5 hash value is then written into the outer layer's `manifest.json` file to form the verification information of the resource package, so that the package content can be verified according to the hash value when the client loads the resource.
[0034] It should be noted that when the client subsequently loads or updates offline package resources, it can verify whether the file has been tampered with or errors occurred during the transmission process by comparing the hash value of the local resource with the record value in `manifest.json`. If the hash value matches, the client can confirm the integrity of the resource package, avoiding loading failures caused by data corruption or inconsistency, and providing an additional layer of protection during the update and loading of client resources.
[0035] S102, when a user accesses a page containing static resources, it is determined whether the resource requested by the page exists in the local storage according to the resource path of the page request. If so, the local resource is directly loaded, bypassing the HTTP request.
[0036] It should be noted that in this embodiment, when a user accesses a page containing static resources, the client will first detect the resource path of the page request to determine whether the requested resource is already in the local storage. The client intercepts the static resource request of the page, and thus preferentially searches for the corresponding file path in the local resource directory. If it is detected that the requested resource already exists in the local storage, the client will directly load the resource from the local without initiating an HTTP request through the network to obtain the corresponding resource content. The localized loading method of resources significantly reduces the number of network requests, avoids loading delays caused by network delays or instability, and improves page response speed and user access experience.
[0037] Furthermore, in this embodiment, the client obtains the request address of the static resource in the page through the resource request function of WebView, and intercepts the request to perform optimization processing of local resource loading. When a page resource is requested, the client extracts the corresponding path value according to the requested resource address, and uses the path value to match the relevant configuration of the offline package to determine whether the resource already exists locally. Based on the information of the offline package configuration, the client further determines whether the resource request has reached the "hit limit" defined in the configuration; if the limit is reached, the client does not intercept the request, but instead executes online resource loading to ensure that local resources are used only when necessary.
[0038] During the resource matching and interception process, the client also performs MD5 encryption on the resource address to generate the resource package directory name of the current page, and combines it with the version number in the offline package configuration to form a complete path to the local resource. Next, the client checks whether the path contains a "cur" folder that can load resources to determine the availability of the resource. If the cur folder does not exist, the system will determine that the local resource is missing, and the client will abandon local loading and instead load resources from online to ensure the integrity and availability of the page. In addition, when the resource requested by the page has not hit the local resource and the offline package configuration of the current page has not reached the activation limit, the client will perform the offline package resource download and decompression operations according to the preset strategy, so that the resource can be loaded locally during subsequent access.
[0039] In a possible implementation of the present invention, the basic information file includes a unique identifier, a version number, a file type, and a checksum of the static resource.
[0040] Among them, the unique identifier can accurately identify each resource file, ensuring that the client does not mistakenly use other files when loading resources.
[0041] The version number is used to track the update status of the resource, allowing the client to determine whether the resource needs to be updated or re-downloaded, so as to always maintain the latest resource status.
[0042] The file type records the specific type of the resource (such as CSS, JS, images, etc.), which makes it easier for the client to perform processing optimization based on the file type during the loading process, thereby improving the efficiency of resource loading.
[0043] In terms of ensuring resource integrity, checksums (usually using MD5 or SHA hash values) are embedded in the basic information file. When the client loads a local resource, the checksum is compared with the hash value of the local file to verify the integrity and correctness of the file. This reduces loading failures caused by transmission errors or file corruption.
[0044] See also Figure 2 The second aspect of the present invention provides a device for loading static resources of a web page, comprising: The compressed package acquisition unit 201 downloads the static resource compressed package and its basic information files of the H5 project from the remote server through a network request when the client application is started, and stores the static resource compressed package and its basic information files in the local storage, wherein the compressed package is generated by the front end by packaging the static resources required by the client's H5 project based on the plug-in; The static resource loading unit 202 is used to determine whether the resource requested by the page exists in the local storage according to the resource path of the page request when the user visits the page containing the static resource. If so, the local resource is directly loaded to bypass the HTTP request.
[0045] A third aspect of the present invention provides a device for loading static resources of a web page, characterized in that it includes a memory and a processor, wherein a computer program is stored in the memory, and the computer program can be executed by the processor to implement a method for loading static resources of a web page as described in any one of the above items.
[0046] A fourth aspect of the present invention provides a computer-readable storage medium, characterized in that a computer program is stored therein, and the computer program can be executed by a processor of a device where the computer-readable storage medium is located to implement a method for loading static resources of a web page as described in any one of the above items.
[0047] Based on a method, device, equipment and storage medium for loading static resources of a web page provided by the present invention, when the application on the client is started, a compressed package and its basic information files are downloaded from a remote server through a network request, and stored in a local storage. Then, when a user accesses a page containing static resources, it is determined whether the resources requested by the page exist in the local storage according to the resource path of the page request. If so, the local resources are directly loaded, bypassing the HTTP request, thereby reducing the H5 page loading time and improving the user experience.
[0048] Exemplarily, the computer program described in the third aspect and the fourth embodiment of the present invention can be divided into one or more modules, and the one or more modules are stored in the memory and executed by the processor to complete the present invention. The one or more modules can be a series of computer program instruction segments that can complete specific functions, and the instruction segments are used to describe the execution process of the computer program in the loading device for implementing a web page static resource. For example, the device described in the second aspect of the present invention.
[0049] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the method for loading static resources of a web page, and uses various interfaces and lines to connect the various parts of the method for loading static resources of a web page.
[0050] The memory can be used to store the computer program and / or module, and the processor realizes various functions of a method for loading static resources of a web page by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store the application required for operating the loading device and at least one function (such as a sound playback function, a text conversion function, etc.); the data storage area can store data created according to the use of the mobile phone (such as audio data, text message data, etc.). In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0051] Wherein, if the implemented module is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0052] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0053] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for loading static resources of a web page, characterized in that: include: When the client application is started, it downloads the static resource compression package and its basic information files of the H5 project from the remote server through a network request, and stores the static resource compression package and its basic information files in the client local file, wherein the compression package is generated by the front end by packaging the static resources required by the client's H5 project based on the plug-in; When a user accesses a page containing static resources, it is determined whether the resource requested by the page exists in the local storage according to the resource path of the page request. If so, the local resource is directly loaded, bypassing the HTTP request.
2. A method for loading static resources of a web page according to claim 1, characterized in that: When the client application is started, it downloads the static resource compression package and its basic information files of the H5 project from the remote server through a network request, and stores the static resource compression package and its basic information files in the client local file, specifically: When the application starts, it queries the remote server to obtain the configuration list of all offline packages, and performs corresponding operations based on the queried configuration to detect local resources; When the backend management end edits the offline package configuration, the server end actively notifies the client end through IM events to update the configuration and update and download local resources; According to the preset trigger scenario configuration, the download logic of the offline package resources is triggered when the user enters the specified page, and the download logic is distributed to the required services; wherein, the download logic includes: comparing the version number in the offline package configuration and the version number of the local resource, when the local version is not equal to the version in the configuration and the mobile phone storage space is sufficient, downloading a new resource package according to the resource package address; splitting the resource file into the .download file being downloaded, the .zip file that has been downloaded, the temp folder being decompressed, and the cur folder of complete resources that can be loaded.
3. A method for loading static resources of a web page according to claim 2, characterized in that: When the application is started, it queries the remote server to obtain the configuration list of all offline packages, and performs corresponding operations based on the queried configuration to detect local resources, specifically: When the offline package function switch in the configuration is turned off, no offline package related logic processing is performed; According to the version number information in the offline package configuration, delete the old versions and local resources that are not in the configuration list and have not been used for a long time, and control the timing and activation quantity of resource downloads according to the pre-download strategy, pre-download trigger scenario and activation quantity limit in the offline package configuration.
4. A method for loading static resources of a web page according to claim 1, characterized in that: The compressed package is generated by the front-end based on the plug-in by packaging the static resources of the H5 project, specifically: Get project information, parse index.html in the project root directory, and use the content in the title tag as the offline package identifier; Generate the current offline package version number, query whether the version number is specified through the parameter through process.argv, if so, use the provided version number, if not, check whether the manifest.json in the main repository exists, if so, get the version field and add 1 as the version number, if not, build the first version number; The project information, offline package version number, generation time, generation project name, and generation environment information are packaged to generate a manifest.json file, and then packaged into a zip compressed package using archiver.
5. A method for loading static resources of a web page according to claim 4, characterized in that: Also includes: Generate the md5 hash value of the zip compressed package through the crypto module, and write the hash value into the outer manifest.json for subsequent package verification.
6. A method for loading static resources of a web page according to claim 1, characterized in that: When a user accesses a page containing static resources, it is determined whether the resource requested by the page exists in the local storage according to the resource path of the page request. If so, the local resource is directly loaded, bypassing the HTTP request, and further comprising: Obtain the resource address through the resource request provided by WebView, and intercept the resource request to perform local resource loading processing; Obtaining a corresponding path value according to the resource address, and obtaining a corresponding offline package configuration based on the path value match; Determine whether the current page has reached the upper limit of the hit amount according to the configuration information of the offline package configuration, and if so, do not intercept and execute online resource loading; The resource address is converted through md5 encryption to obtain the directory name of the resource package of the current page, and is concatenated with the version number in the offline package configuration to form a complete path of the local resource. Check whether there is a cur folder under the path. If not, it is determined that the local resource does not exist and online resource loading is executed; When the page fails to load local resources and the current page configuration does not reach the activation limit, the offline package resources are downloaded and decompressed.
7. A method for loading static resources of a web page according to claim 1, characterized in that: The basic information file includes a unique identifier, a version number, a file type, and a checksum of a static resource.
8. A device for loading static resources of a web page, characterized in that: include: A compressed package acquisition unit, when the client application is started, downloads the static resource compressed package and its basic information files of the H5 project from the remote server through a network request, and stores the static resource compressed package and its basic information files in the local storage, wherein the compressed package is generated by the front end by packaging the static resources required by the client's H5 project based on the plug-in; The static resource loading unit is used to determine whether the resource requested by the page exists in the local storage according to the resource path of the page request when the user visits the page containing the static resource. If so, the local resource is directly loaded, bypassing the HTTP request.
9. A device for loading static resources of a web page, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement a method for loading static resources of a web page as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: A computer program is stored, and the computer program can be executed by a processor of the device where the computer-readable storage medium is located to implement a method for loading static resources of a web page as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Method, device and system for acquiring resources
CN107528718A
Offline package-based APP module update method
CN108717359A
Webpage resource loading method and device
WO2015161658A1
Cited By
Vehicle-mounted equipment network upgrading method and system and storage medium
CN119960799A
Method and system for requesting accelerated rendering by mobile application
CN121658735A
