Page resource acquisition method and device, computer equipment and storage medium
By inputting H5 page resources into the automated script module, aggregating them into offline compression packages and generating path information, the problem of inflexible offline resource updates in the existing technology is solved, and the rapid loading and management of H5 page resources is achieved, improving user experience and system efficiency.
Patent Information
- Application Number
- CN202411386409.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-02-18
AI Technical Summary
The existing offline resource loading solution can only place H5-related files under the index in advance and package them with the application. The relevant resources in the index cannot be updated, resulting in the loss of the fast iteration flexibility of H5. If offline packages are not used, online The loading of H5 is a long time to take a white screen, and the page cannot be opened in seconds, which makes the user experience poor.
Provide a method for obtaining page resources. By obtaining the client page resources and resource information to be published, the page resources are input into the automation script module, aggregated into the offline compression package, and generate path information, including identification information, version number and download Link, add to the resource library when the client is published, monitor resource acquisition requests, match version numbers, and download the latest offline compressed package.
While improving resource loading speed, we obtain corresponding page resources to ensure smooth use of users in various scenarios, realize the rapid acquisition and management of resources, and improve user experience and system efficiency.
Smart Images

Figure CN119474583A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of H5 technology, and in particular to a method, device, computer equipment and storage medium for acquiring page resources. Background Art
[0002] In the process of developing and using mobile applications, H5 technology has been widely used in the financial field due to its cross-platform and easy-to-update features. However, when users install an application for the first time or update an application, if a large amount of H5 resources need to be downloaded from a remote server, it will take a long time and a large amount of traffic, which can easily lead to a poor user experience. At the same time, if there is no good offline support, users will not be able to use the application normally in scenarios where there is no network or the network is unstable.
[0003] Offline packages are the most commonly used optimization technology. By downloading the resources required for H5 rendering in advance, local cache resources are directly used during loading to avoid additional network requests and improve loading speed. The current solution for loading offline resources can only put H5 related files in the index in advance and package them together with the application. The related resources in the index cannot be updated, which loses the flexibility of H5's quick iteration. If offline packages are not used, the online H5 loading white screen time is long, the page cannot be opened in seconds, and the user experience is poor.
[0004] Therefore, there is an urgent need for a page resource acquisition method for H5 that can obtain corresponding page resources while improving the speed of resource loading, ensuring that users can use it smoothly in various scenarios. Summary of the invention
[0005] The present application provides a method, device, computer equipment and storage medium for obtaining page resources, aiming to solve the problem that the current offline resource loading solution can only put H5 related files under the index in advance and package them together with the application, and the related resources in the index cannot be updated, thus losing the flexibility of quick iteration of H5. If the offline package is not used, the online H5 loading white screen time is long, the page cannot be opened in seconds, and the user experience is poor. The method provided can obtain the corresponding page resources while improving the speed of resource loading, ensuring that users can use it smoothly in various scenarios.
[0006] In a first aspect, the present application provides a method for obtaining page resources, comprising:
[0007] Obtaining the client's page resources to be published and resource information corresponding to the page resources;
[0008] Inputting the page resources into a preset automation script module, wherein the automation script module is used to aggregate the page resources into an offline compression package;
[0009] Generate path information of the page resource corresponding to the offline compressed package according to the resource information; the path information at least includes identification information, version number and download link corresponding to the page resource;
[0010] When the client publishes, the offline compressed package and the corresponding path information are added to the resource library corresponding to the client;
[0011] When monitoring that the client receives a resource acquisition request, intercepting and parsing the resource acquisition request, and obtaining a request file identifier corresponding to the resource request;
[0012] Matching the requested file identifier with each of the identification information in the resource library, and obtaining a version number and a download link corresponding to the successfully matched identification information;
[0013] If it is determined that the version number is the latest version corresponding to the page resource, the offline compressed package is downloaded according to the download link, the offline compressed package is decompressed to obtain the page resource, and the response to the resource acquisition request is completed.
[0014] In some embodiments, the page resources include at least web page content, images, style sheets and script files; before inputting the page resources into a preset automation script module, it also includes: determining the first target resource to be packaged in each of the page resources according to a preset compression rule; wherein the compression rule includes one or more of whether the resource type is a pending resource type, whether the file size is within a preset range, and whether the update time is within a preset time interval; and inputting the first target resource into a preset automation script module.
[0015] Exemplarily, before inputting the first target resource into a preset automation script module, the process also includes: determining the page type corresponding to the page resource based on the resource information; determining each of the page resources except the first target resource as a pending resource; calculating the dependency relationship between each of the pending resources and the page type; and determining a second target resource among the pending resources based on the dependency relationship, so as to input the first target resource and the second target resource into the preset automation script module.
[0016] In some embodiments, generating path information of the page resource corresponding to the offline compressed package based on the resource information includes: parsing the page resource to obtain a unique identifier of the page resource and the version number of the current version; generating the identification information based on the unique identifier; generating a download link corresponding to the page resource, wherein the download link includes the storage path of the offline compressed package; and combining the identification information, version number and download link to generate the path information.
[0017] In some embodiments, adding the offline compressed package and the corresponding path information to the resource library corresponding to the client includes: obtaining the resource library structure corresponding to the client before the client publishes; the resource library structure includes the storage path of the resource library and the corresponding database; storing the offline compressed package in the resource library; generating index information based on the identification information, version number and download link of the page resource; updating the index file of the resource library based on the index information; wherein, the index file is used to retrieve the path information corresponding to the page resource in the storage path of the resource library.
[0018] In some embodiments, if the request file identifier and each of the identification information in the resource library fail to match, the method further includes: downloading the page resource corresponding to the request file identifier from a preset online resource library to complete the response to the resource acquisition request; or, canceling the interception of the resource acquisition request, and the client responds to the resource acquisition request to complete the online acquisition of the page resource corresponding to the request file identifier.
[0019] In some embodiments, if it is determined that the version number is not the latest version corresponding to the page resource, the method also includes: generating a download request based on the identification information; sending the download request to the cloud to receive the page resource returned by the cloud; and replacing the page resource in the offline compressed package based on the page resource returned by the cloud.
[0020] In a second aspect, the present application provides a page resource device, including:
[0021] A resource acquisition unit, used to acquire the page resources of the client to be published and the resource information corresponding to the page resources;
[0022] A resource input unit, used to input the page resources into a preset automation script module, and the automation script module is used to aggregate the page resources into an offline compression package;
[0023] A path generation unit, configured to generate path information of the page resource corresponding to the offline compressed package according to the resource information; the path information at least includes identification information, version number and download link corresponding to the page resource;
[0024] A path adding unit, used for adding the offline compressed package and the corresponding path information to the resource library corresponding to the client when the client publishes;
[0025] A request monitoring unit, configured to intercept and parse the resource acquisition request when monitoring that the client receives the resource acquisition request, and obtain a request file identifier corresponding to the resource request;
[0026] An identification matching unit, used to match the requested file identification with each identification information in the resource library, and obtain a version number and a download link corresponding to the successfully matched identification information;
[0027] The request response unit is used to download the offline compressed package according to the download link if it is determined that the version number is the latest version corresponding to the page resource, decompress the offline compressed package to obtain the page resource, and complete the response to the resource acquisition request.
[0028] In a third aspect, the present application further provides a computer device, including:
[0029] Memory and processor;
[0030] The memory is used to store computer programs;
[0031] The processor is used to execute the computer program and implement the steps of the page resource acquisition method described in the first aspect when executing the computer program.
[0032] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the steps of the page resource acquisition method described in the first aspect above.
[0033] The present application discloses a method, device, computer equipment and storage medium for obtaining page resources. The method first obtains the page resources to be published by the client and the corresponding resource information (such as identification information, version number, download link, etc.). Then the page resources are input into a preset automatic script module, which is responsible for aggregating the page resources into an offline compressed package for centralized management and transmission. Then, according to the resource information, the path information of the page resources in the offline compressed package is generated, including the identification information, version number and download link of the page resources. These path information correspond to the resource files one by one and are used for subsequent resource request processing. Further, when the client publishes, the offline compressed package and its path information will be added to the resource library corresponding to the client to provide support for subsequent resource acquisition requests. Furthermore, the provided method monitors the resource acquisition request of the client in real time, obtains the corresponding request file identification by intercepting and parsing the request, and matches the corresponding identification information in the resource library. After the match is successful, the provided method will check the requested resource version number. If it is the latest version, the corresponding offline compressed package will be obtained and decompressed through the download link, and finally respond to the resource request. The provided method effectively optimizes the acquisition, transmission and management processes of page resources through the combination of automated scripts and offline compression packages, and improves the resource responsiveness and user experience of clients on any operating system.
[0034] At the same time, the provided method also has the following beneficial effects:
[0035] 1. Improve resource acquisition efficiency: Centrally manage page resources through offline compression packages, which can reduce network delays when clients request resources and speed up the loading of page resources.
[0036] 2. Simplified version management and updates: The version number matching mechanism in the solution ensures that the client always obtains the latest version of the page resources, reduces version inconsistency issues, and improves the accuracy of resource management.
[0037] 3. Resource distribution optimization: Through the allocation of path information and download links, the resource distribution and download process can be better controlled, reducing errors and repeated download problems during resource transmission.
[0038] 4. High degree of automation: The use of automated script modules greatly reduces the need for manual operations and improves the overall system automation level and resource processing efficiency.
[0039] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 This is a schematic flow chart of the steps of a first method for acquiring page resources provided by an embodiment of the present application;
[0042] Figure 2 is a schematic flow chart of the steps of a method for generating path information provided by an embodiment of the present application;
[0043] Figure 3 is a schematic flow chart of the steps of a method for adding path information provided by an embodiment of the present application;
[0044] Figure 4 It is a structural diagram of a page resource acquisition device provided in an embodiment of the present application;
[0045] Figure 5 It is a schematic block diagram of the structure of a computer device provided in one embodiment of the present application.
[0046] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0049] It should be understood that, in order to facilitate the clear description of the technical solutions of the embodiments of the present invention, in the embodiments of the present invention, the words "first", "second", etc. are used to distinguish the same items or similar items with substantially the same functions and effects. Those skilled in the art can understand that the words "first", "second", etc. do not limit the quantity and execution order, and the words "first", "second", etc. do not necessarily limit the difference.
[0050] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0051] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0052] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0053] In the process of developing and using mobile applications, H5 technology has been widely used in the financial field due to its cross-platform and easy-to-update features. However, when users install an application for the first time or update an application, if a large amount of H5 resources need to be downloaded from a remote server, it will take a long time and a large amount of traffic, which can easily lead to a poor user experience. At the same time, if there is no good offline support, users will not be able to use the application normally in scenarios where there is no network or the network is unstable.
[0054] Offline packages are the most commonly used optimization technology. By downloading the resources required for H5 rendering in advance, local cache resources are directly used during loading to avoid additional network requests and improve loading speed. The current solution for loading offline resources can only put H5 related files in the index in advance and package them together with the application. The related resources in the index cannot be updated, which loses the flexibility of H5's quick iteration. If offline packages are not used, the online H5 loading white screen time is long, the page cannot be opened in seconds, and the user experience is poor.
[0055] Therefore, there is an urgent need for a page resource acquisition method for H5 that can obtain corresponding page resources while improving the speed of resource loading, ensuring that users can use it smoothly in various scenarios.
[0056] It should be noted that H5 pages are widely used in various APPs due to their cross-platform, real-time update, and easy development features. Since the loading speed of H5 is very dependent on the network environment, in order to improve the user experience, it is very important to optimize the loading speed of H5. In H5 applications, offline page resources are usually downloaded in advance by downloading the HTML / JS / CSS resources required for H5 rendering, and local cache resources are directly used during loading to avoid additional network requests and improve the loading speed. At present, system markets such as Hongmeng do not provide relevant offline page resource download solutions. For example, the current offline resource loading solution of Hongmeng system can only put H5 related files under resources in advance and package them together with APP. Resources related to resources cannot be updated, which loses the flexibility of H5's quick iteration. If the offline package is not used, the online H5 will have a long white screen loading time, and the page cannot be opened in seconds, resulting in a poor user experience.
[0057] To solve the above problems, please refer to Figure 1 , Figure 1 This is a schematic flow chart of a page resource acquisition method provided by an embodiment of the present application. The page resource acquisition method can be implemented by a computer device, which can be deployed on a single server or a server cluster. It can also be deployed on a handheld terminal, a laptop computer, a wearable device, or a robot.
[0058] It should be noted that the provided method can be applied not only to financial systems and other clients where there are many page resources that need to be loaded, but also to systems such as medical and educational systems, and the embodiments of the present application are not limited to this.
[0059] To solve the above problems, please refer to Figure 1 Specifically, Figure 1 As shown, the provided page resource acquisition method includes steps S101 to S107. The details are as follows:
[0060] Step S101: Acquire the client's page resources to be published and the resource information corresponding to the page resources.
[0061] Specifically, the method extracts page resources (such as HTML, CSS, JS files, etc.) and their related resource information (such as identification, version number, file name, etc.) from the server or development environment to ensure that the acquired resources and information are up to date so that subsequent steps can correctly manage and publish resources.
[0062] Step S102: input the page resources into a preset automation script module, and the automation script module is used to aggregate the page resources into an offline compression package.
[0063] Specifically, the method packages the acquired page resources into a compressed package for offline use through an automated script module. The automated script reduces manual intervention, ensures that resources can be packaged quickly and efficiently, reduces resource volume, and facilitates transmission and management.
[0064] In some embodiments, the page resources include at least web page content, images, style sheets and script files; before the page resources are input into a preset automation script module, it also includes: determining the first target resource to be packaged in each page resource according to a preset compression rule; wherein the compression rule includes one or more of whether the resource type is a pending resource type, whether the file size is within a preset range, and whether the update time is within a preset time interval; and inputting the first target resource into the preset automation script module.
[0065] Page resources include at least web page content, images, style sheets and script files. Before the page resources are input into the preset automation script module, the first target resources to be packaged are determined according to the preset compression rules. Through the collection and classification of page resources. Then, the first target resources to be packaged are screened out according to the above compression rules (for example, all HTML, CSS, and JS files may need to be packaged, while image resources are selectively packaged according to file size). These first target resources are then input into the preset automation script module for further processing. Through the preset compression rules, page resources can be efficiently managed and screened to ensure that only required resources are packaged, which improves the efficiency of resource utilization. At the same time, through the screening rules, the size of the packaged resources is reduced, thereby increasing the speed of transmission and loading. It also reduces human intervention, and uses the automation script module to improve the speed and accuracy of resource sorting and packaging.
[0066] Exemplarily, before inputting the first target resource into a preset automation script module, the method further includes: determining the page type corresponding to the page resource based on resource information; determining each page resource except the first target resource as a pending resource; calculating the dependency relationship between each pending resource and the page type; and determining the second target resource among the pending resources based on the dependency relationship, so as to input the first target resource and the second target resource into the preset automation script module.
[0067] Classify page resources by resource information, for example, divide them into different types of pages according to their content, purpose, etc. Exclude the part that has been determined as the first target resource, and mark the remaining resources as pending resources. Calculate the dependency relationship between the pending resources and the page type, such as inter-module references and style dependencies. Select the second target resource that is closely related to the page type from the pending resources. Input these two groups of target resources (the first and second target resources) into the automation script module.
[0068] Then, through the analysis of page types and dependencies, resources closely related to specific page types are selected (for example, an HTML file may depend on multiple CSS and JS files, so these files should be packaged together), which improves the pertinence and completeness of resource packaging. By analyzing dependencies, unnecessary resource packaging is avoided, redundant data is reduced, and resource utilization and transmission efficiency are improved. The modularization and refinement of resource selection are achieved, which is conducive to improving the maintainability and scalability of the system.
[0069] In summary, the above embodiments, in terms of technical content, propose a method for efficiently managing and packaging page resources by refining the resource selection and packaging process; and in terms of beneficial effects, they significantly improve resource utilization efficiency, transmission speed and overall system performance.
[0070] Step S103: Generate path information of the page resource corresponding to the offline compressed package according to the resource information; the path information at least includes identification information, version number and download link corresponding to the page resource.
[0071] Specifically, the method generates path information, including identification information, version number and download link of page resources, which can provide detailed identification and version control for offline packages, ensure that the client can correctly locate resources, and improve the flexibility and accuracy of resource management.
[0072] In some embodiments, Figure 2 As shown, generating path information of page resources corresponding to the offline compressed package according to resource information includes steps S103a to S103d.
[0073] Step S103a: parse the page resource to obtain the unique identifier of the page resource and the version number of the current version.
[0074] By parsing the page resource file, extract its unique identifier, such as file name, hash value, etc. Get the current version number for version control.
[0075] Step S103b. Generate identification information according to the unique identifier.
[0076] Generates identification information using a unique identifier, either in a simplified form or in a format that is consistent with other resource identifiers in the repository.
[0077] Step S103c. Generate a download link corresponding to the page resource, wherein the download link includes the storage path of the offline compressed package.
[0078] By creating a download link containing the path to the offline zip archive storage. The download link should be a unique and easily accessible URL or file path.
[0079] S103d. Combine the identification information, version number and download link to generate path information.
[0080] Combine the generated identification information, version number, and download link to form complete path information.
[0081] Therefore, by parsing the page resources and generating unique identifiers and version numbers, the path information of each resource is ensured to be unique and easy to manage. The generation of identification information helps to quickly match and find resources, improving the efficiency of resource access and management. The generated version number and download link are stored together with the path information of the resource to ensure that the client can always obtain the latest version of the resource. Through version control, the use of old version resources is avoided, which improves the stability and consistency of the system. The generated download link points to the storage path of the offline compressed package, and users can quickly download and decompress resources, reducing the time to obtain resources. The combination of storage path information simplifies the distribution and access process of resources. The path information and download link are generated through automated steps, which reduces the errors caused by manual operations and improves the automation and accuracy of the overall process.
[0082] In summary, the above embodiment forms a complete resource path management solution by parsing page resources, generating unique identifiers and version numbers, creating download links and combining path information through detailed steps. This not only improves the efficiency of resource management and acquisition, but also ensures resource version control, reduces the possibility of errors, and provides significant convenience for client publishing and resource library maintenance.
[0083] For example, assume that a page resource is "homepage.html", its unique identifier is the file name "homepage.html", and the version number is "v1.3". The identification information generated based on "homepage.html" may be "HPG123". The download link may be "http: / / example.com / resources / homepage_v1.3.zip", and the storage path is the resource location on the server. The identification information "HPG123", the version number "v1.3" and the download link "http: / / example.com / resources / homepage_v1.3.zip" are combined to form the path information.
[0084] Step S104: When the client publishes, the offline compressed package and the corresponding path information are added to the resource library corresponding to the client.
[0085] Specifically, by storing offline compressed packages and their path information in the client's resource library, the client can call these resources at any time. The resources are stored in the client in a structured manner, reducing the delay in resource acquisition and ensuring the availability of resources.
[0086] In some embodiments, Figure 3 As shown, adding the offline compressed package and the corresponding path information to the resource library corresponding to the client includes steps S104a to S104d.
[0087] Step S104a. Before the client publishes, obtain the resource library structure corresponding to the client; the resource library structure includes the storage path of the resource library and the corresponding database.
[0088] Before publishing on the client, obtain the storage path of the resource library and the corresponding database structure. The resource library structure includes the resource file storage path and the database used to record resource information.
[0089] Step S104b: Store the offline compressed package in the resource library.
[0090] Store the offline compressed package to the specified location according to the storage path of the resource library.
[0091] Step S104c. Generate index information according to the identification information, version number and download link of the page resource.
[0092] Index information may include the resource's identification information, version number, and download link, so that the resource can be quickly retrieved and accessed in the resource library.
[0093] Step S104d. Update the index file of the resource library according to the index information; wherein the index file is used to retrieve the path information corresponding to the page resource in the storage path of the resource library.
[0094] The index file contains the path information and related metadata of all resources in the resource library and is used to retrieve the path information of page resources.
[0095] Then, the resource library structure is obtained to ensure that resources can be stored and managed according to the predetermined structure, which improves the organizational efficiency of the resource library. Storing offline compressed packages in the resource library provides an effective resource storage method for the client and supports the efficient management of a large number of resources. By generating and updating index files, rapid retrieval and positioning of resources are achieved, improving the speed of resource access. The generation and update of index information enables clients to quickly match and find required resources and reduce access delays. The maintenance of index information and index files ensures the consistency and accuracy of information in the resource library and avoids resource search errors. Through a unified indexing mechanism, manual misoperation is reduced and the stability and reliability of the system are improved. At the same time, automated storage and index updates simplify the process of resource publishing and updating, reduce manual intervention, and improve work efficiency. The client can automatically obtain the latest resource version when publishing to ensure that the resources are always up to date.
[0096] In summary, step S104a to step S104d provide a complete resource management solution by obtaining the resource library structure, storing the offline compressed package, generating index information and updating the index file through detailed steps. This not only effectively improves the management efficiency of the resource library and the resource access speed, but also ensures the consistency and accuracy of the resources, simplifies the resource update process, and provides strong support for the efficient and stable operation of the client.
[0097] Exemplarily, the client resource library structure may include a storage path such as " / resources / " and a database structure such as SQLite or other forms of resource management databases. Assume that the compressed package of the page resource is named "homepage_v1.3.zip" and store it in the path " / resources / ". Generate index information based on the resource identification information (e.g. "HPG123"), version number "v1.3", and download link "http: / / example.com / resources / homepage_v1.3.zip". Update the index file (e.g. index.db or index.json) to include the new path information and metadata.
[0098] Step S105: When it is detected that the client receives a resource acquisition request, the resource acquisition request is intercepted and parsed to obtain a request file identifier corresponding to the resource request.
[0099] Specifically, when the client receives a resource request, the request is intercepted and the file identifier is parsed (for example, in the Hongmeng operating system, the onInterceptRequest listener of the webview is used to intercept the request event to achieve the purpose of intercepting the request) for subsequent resource matching. This ensures that each resource request can be effectively processed and responded to through offline resources first, improving the response speed, preventing invalid or erroneous requests, and optimizing the distribution and use efficiency of resources.
[0100] Step S106: Match the requested file identifier with each identifier in the resource library, and obtain the version number and download link corresponding to the successfully matched identifier.
[0101] Specifically, by matching the requested file identifier with the resource identifier information in the resource library, the corresponding version number and download link are found, ensuring that the client can accurately find the requested resource, preventing the use of old version resources or downloading of wrong files, and improving the accuracy of resource matching.
[0102] In some embodiments, if the requested file identifier and each identification information in the resource library fail to match, the method further includes: downloading a page resource corresponding to the requested file identifier in a preset online resource library to complete the response to the resource acquisition request.
[0103] If the requested file identifier and each identifier in the resource library fail to match, the page resource corresponding to the requested file identifier is downloaded from the preset online resource library. The response to the resource acquisition request is completed. Then, when the resource acquisition request does not match the local resource, the processing logic realizes the flexibility and reliability of resource acquisition by downloading resources from the preset online resource library or canceling the interception of resource requests. This not only improves the flexibility of resource management and access, but also effectively guarantees the user experience, providing strong support for the efficient maintenance of the resource library and the stable operation of the system.
[0104] For example, suppose the client requests to obtain a page resource with a resource identifier of "resource_XYZ", but no matching identifier information is found in the local resource library. If the online resource download mechanism is enabled, the provided method will search for "resource_XYZ" in the preset online resource library and download the corresponding resource file. After the download is completed, the client's resource acquisition request is responded to and the downloaded resource is provided.
[0105] In some embodiments, if the requested file identifier and each identification information in the resource library fail to match, the method further includes: canceling the interception of the resource acquisition request, and the client responds to the resource acquisition request to complete the online acquisition of the page resource corresponding to the requested file identifier.
[0106] If the requested file identifier and each identifier in the resource library fail to match, the intercepted resource acquisition request is canceled, allowing the client to continue to respond to the resource acquisition request. The client obtains the page resource corresponding to the requested file identifier online. Then, when the resource acquisition request does not match the local resource, the processing logic realizes the flexibility and reliability of resource acquisition by downloading resources from the preset online resource library or canceling the intercepted resource request. This not only improves the flexibility of resource management and access, but also effectively guarantees the user experience, providing strong support for the efficient maintenance of the resource library and the stable operation of the system.
[0107] For example, suppose the client requests to obtain a page resource with a resource identifier of "resource_XYZ", but no matching identifier is found in the local resource library. The provided method will cancel the interception of the resource acquisition request and allow the client to process the request on its own. The client will directly initiate a request to the online resource server to obtain the resource corresponding to "resource_XYZ".
[0108] In summary, the above two embodiments for when the request file identifier and each identifier information in the resource library fail to match have the following beneficial effects:
[0109] 1. Enhanced resource acquisition flexibility: When the local resource library cannot meet the request, the system can intelligently turn to the online resource library to flexibly respond to resource acquisition needs. It provides two resource acquisition methods, local and online, to ensure the reliability and continuity of resource acquisition.
[0110] 2. Improve resource access reliability: The online download mechanism ensures that even if local resources are missing, the system can still obtain the required resources through online download, ensuring the integrity of client functions. The online resource library, as a backup resource library, provides additional reliability guarantees.
[0111] 3. Optimize resource management and maintenance: The introduction of online resource libraries reduces the reliance on local resource libraries and facilitates system updates and maintenance. Online download and unblocking mechanisms help reduce the burden on local resource libraries and improve system operation efficiency.
[0112] 4. Ensure user experience: When local resources are missing, resources are supplemented through the online resource library to ensure the continuity and consistency of user experience. Even when there are problems with resource library updates or network transmission, canceling the interception mechanism can ensure that the client obtains the required resources in a timely manner, improving user satisfaction.
[0113] Step S107: If it is determined that the version number is the latest version corresponding to the page resource, download the offline compressed package according to the download link, decompress the offline compressed package to obtain the page resource, and complete the response to the resource acquisition request.
[0114] Specifically, by verifying whether the version number of the resource is the latest, if so, the offline compressed package is obtained and decompressed through the download link to use the page resource. Ensure that the client always uses the latest version of the page resource, reduce resource update delays, and optimize user experience and system efficiency. This helps the client to efficiently manage page resources, ensure the accuracy of resource acquisition and update, and reduce network transmission overhead through offline compressed packages, thereby improving performance. And through the combination of automated scripts and offline compressed packages, the acquisition, transmission and management processes of page resources are effectively optimized, and the resource responsiveness and user experience of clients on any operating system are improved.
[0115] In some embodiments, if it is determined that the version number is not the latest version corresponding to the page resource, the method also includes: generating a download request based on the identification information; sending the download request to the cloud to receive the page resource returned by the cloud; and replacing the page resource in the offline compressed package based on the page resource returned by the cloud.
[0116] The processing steps when the version number is not the latest version corresponding to the page resource, so as to ensure that the client always has the latest resource version. By automatically checking and updating the resource version, the client is ensured to always use the latest version of the page resource, which improves the user experience. Reduces the compatibility and functional issues caused by the client using expired resources. Through the automatic download and update mechanism, the tedious steps and possible errors of manual updates are reduced, and the overall stability and reliability of the system are improved. Regular synchronization of cloud resources ensures the timely update and accuracy of resources. The resource version check, download and update are fully automated, which simplifies the resource management and maintenance process. Provides a set of efficient resource update mechanisms to reduce manual intervention and improve work efficiency. During the resource update process, ensure that users can always quickly obtain the latest functions and content, and improve user satisfaction. Through a reliable resource synchronization mechanism, it is guaranteed that the client can seamlessly update resources during use and reduce problems caused by version inconsistencies.
[0117] This step is flexible in design and can be applied to various resource update scenarios. It is not limited to page resources, but can also be extended to other types of client resources. In cross-platform applications, the cloud-based resource update mechanism enables multiple client devices to update synchronously and maintain consistency.
[0118] In summary, the provided embodiments describe in detail how to ensure timely updates of client resources when the version number is not the latest. This includes generating a download request, sending a request to the cloud, receiving the latest resources, and replacing local resources. This series of operations ensures the latest and reliability of client resources, improves system stability and user experience, and provides a strong guarantee for efficient management, updating, and maintenance of resources.
[0119] For example, assume that the client has a page resource "homepage.html" with version number "v1.2", and the cloud has been updated to version "v1.3". Generate a download request containing identification information (such as "HPG123") and a request to obtain the latest version of the resource. Send the download request to the cloud resource server. Receive the latest version "v1.3" of the "homepage.html" page resource from the cloud. Replace the "homepage.html" (v1.2) in the local offline compressed package with the latest version of the resource (v1.3).
[0120] The provided method can realize offline acquisition of H5 page resources in various operating systems, effectively improving the loading speed of H5 pages and achieving the effect of opening in seconds. The benefits of this solution are:
[0121] 1. Improve user experience: When the APP is released, the offline package is embedded in the application and released. When the user opens the application for the first time, there is no need to rely on the network environment to download the resource, but to start using the application immediately.
[0122] 2. Implement dynamic updates and reduce the number of client releases: When H5 highlights a new version or is released urgently, the application can automatically download and update the H5 offline package by updating the relevant configuration. The application does not need to be re-released and put on the shelf, saving time.
[0123] See also Figure 4 As shown, Figure 4 1 is a schematic diagram of the structure of the page resource acquisition device 200 provided in an embodiment of the present application. The page resource acquisition device 200 is used to execute the steps of the page resource acquisition method shown in the above embodiments. The page resource acquisition device 200 can be a single server or a server cluster, or the page resource acquisition device 200 can be a terminal, which can be a handheld terminal, a laptop computer, a wearable device or a robot, etc.
[0124] like Figure 4 As shown, the page resource acquisition device 200 includes:
[0125] The resource acquisition unit 201 is used to acquire the client's page resources to be published and the resource information corresponding to the page resources;
[0126] A resource input unit 202, used to input the page resources into a preset automation script module, and the automation script module is used to aggregate the page resources into an offline compression package;
[0127] A path generation unit 203 is used to generate path information of the page resource corresponding to the offline compressed package according to the resource information; the path information at least includes identification information, version number and download link corresponding to the page resource;
[0128] A path adding unit 204 is used to add the offline compressed package and the corresponding path information to the resource library corresponding to the client when the client publishes;
[0129] The request monitoring unit 205 is used to intercept and parse the resource acquisition request when monitoring that the client receives the resource acquisition request, and obtain the request file identifier corresponding to the resource request;
[0130] An identification matching unit 206 is used to match the requested file identification with each identification information in the resource library, and obtain a version number and a download link corresponding to the successfully matched identification information;
[0131] The request response unit 207 is used to download the offline compressed package according to the download link if it is determined that the version number is the latest version corresponding to the page resource, decompress the offline compressed package to obtain the page resource, and complete the response to the resource acquisition request.
[0132] In some embodiments, the page resources include at least web page content, images, style sheets and script files; before the page resources are input into a preset automation script module, it also includes: a target determination unit, used to determine the first target resource to be packaged in each of the page resources according to a preset compression rule; wherein the compression rule includes one or more of whether the resource type is a pending resource type, whether the file size is within a preset range, and whether the update time is within a preset time interval; the first target resource is input into the preset automation script module.
[0133] Exemplarily, before inputting the first target resource into a preset automation script module, the target determination unit is further used to: determine the page type corresponding to the page resource based on the resource information; determine each of the page resources except the first target resource as a pending resource; calculate the dependency relationship between each of the pending resources and the page type; determine the second target resource among the pending resources based on the dependency relationship, so as to input the first target resource and the second target resource into the preset automation script module.
[0134] In some embodiments, the path adding unit 204 is also used to: parse the page resource to obtain the unique identifier of the page resource and the version number of the current version; generate the identification information based on the unique identifier; generate a download link corresponding to the page resource, wherein the download link includes the storage path of the offline compressed package; and combine the identification information, version number and download link to generate the path information.
[0135] In some embodiments, the resource input unit 202 is also used to: obtain the resource library structure corresponding to the client before the client publishes; the resource library structure includes the storage path of the resource library and the corresponding database; store the offline compressed package in the resource library; generate index information according to the identification information, version number and download link of the page resource; update the index file of the resource library according to the index information; wherein, the index file is used to retrieve the path information corresponding to the page resource in the storage path of the resource library.
[0136] In some embodiments, if the request file identifier and each identification information in the resource library fail to match, it also includes: an interception cancellation unit, used to cancel the interception of the resource acquisition request, and the client responds to the resource acquisition request to complete the online acquisition of the page resource corresponding to the request file identifier.
[0137] In some embodiments, if the request file identifier and each identification information in the resource library fail to match, it also includes: an online response unit, used to download the page resource corresponding to the request file identifier in a preset online resource library to complete the response to the resource acquisition request.
[0138] In some embodiments, if it is determined that the version number is not the latest version corresponding to the page resource, the method also includes: a cloud download unit, used to generate a download request based on the identification information; send the download request to the cloud to receive the page resource returned by the cloud; replace the page resource in the offline compressed package according to the page resource returned by the cloud.
[0139] It should be noted that technical personnel in the relevant field can clearly understand that for the convenience and conciseness of description, the specific working processes of the page resource acquisition device and each module described above can refer to the corresponding processes in the page resource acquisition method embodiments described in the above embodiments, and will not be repeated here.
[0140] The above-mentioned page resource acquisition method can be implemented in the form of a computer program. The computer program can be Figure 4 Run on the device shown.
[0141] See also Figure 5 , Figure 5 1 is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application. The computer device includes a processor, a memory and a network interface connected via a device bus, wherein the memory may include a storage medium and an internal memory.
[0142] The storage medium can store an operating device and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any one of the page resource acquisition methods.
[0143] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0144] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any page resource acquisition method.
[0145] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will appreciate that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present application, and does not constitute a limitation on the terminal to which the scheme of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0146] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be 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. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0147] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0148] Obtaining the client's page resources to be published and resource information corresponding to the page resources;
[0149] Inputting the page resources into a preset automation script module, wherein the automation script module is used to aggregate the page resources into an offline compression package;
[0150] Generate path information of the page resource corresponding to the offline compressed package according to the resource information; the path information at least includes identification information, version number and download link corresponding to the page resource;
[0151] When the client publishes, the offline compressed package and the corresponding path information are added to the resource library corresponding to the client;
[0152] When monitoring that the client receives a resource acquisition request, intercepting and parsing the resource acquisition request, and obtaining a request file identifier corresponding to the resource request;
[0153] Matching the requested file identifier with each of the identification information in the resource library, and obtaining a version number and a download link corresponding to the successfully matched identification information;
[0154] If it is determined that the version number is the latest version corresponding to the page resource, the offline compressed package is downloaded according to the download link, the offline compressed package is decompressed to obtain the page resource, and the response to the resource acquisition request is completed.
[0155] In some embodiments, the page resources include at least web page content, images, style sheets and script files; before inputting the page resources into a preset automation script module, it also includes: determining the first target resource to be packaged in each of the page resources according to a preset compression rule; wherein the compression rule includes one or more of whether the resource type is a pending resource type, whether the file size is within a preset range, and whether the update time is within a preset time interval; and inputting the first target resource into a preset automation script module.
[0156] Exemplarily, before inputting the first target resource into a preset automation script module, the process also includes: determining the page type corresponding to the page resource based on the resource information; determining each of the page resources except the first target resource as a pending resource; calculating the dependency relationship between each of the pending resources and the page type; and determining a second target resource among the pending resources based on the dependency relationship, so as to input the first target resource and the second target resource into the preset automation script module.
[0157] In some embodiments, generating path information of the page resource corresponding to the offline compressed package based on the resource information includes: parsing the page resource to obtain a unique identifier of the page resource and the version number of the current version; generating the identification information based on the unique identifier; generating a download link corresponding to the page resource, wherein the download link includes the storage path of the offline compressed package; and combining the identification information, version number and download link to generate the path information.
[0158] In some embodiments, adding the offline compressed package and the corresponding path information to the resource library corresponding to the client includes: obtaining the resource library structure corresponding to the client before the client publishes; the resource library structure includes the storage path of the resource library and the corresponding database; storing the offline compressed package in the resource library; generating index information based on the identification information, version number and download link of the page resource; updating the index file of the resource library based on the index information; wherein, the index file is used to retrieve the path information corresponding to the page resource in the storage path of the resource library.
[0159] In some embodiments, if the request file identifier and each of the identification information in the resource library fail to match, the method further includes: downloading the page resource corresponding to the request file identifier from a preset online resource library to complete the response to the resource acquisition request; or, canceling the interception of the resource acquisition request, and the client responds to the resource acquisition request to complete the online acquisition of the page resource corresponding to the request file identifier.
[0160] In some embodiments, if it is determined that the version number is not the latest version corresponding to the page resource, the method also includes: generating a download request based on the identification information; sending the download request to the cloud to receive the page resource returned by the cloud; and replacing the page resource in the offline compressed package based on the page resource returned by the cloud.
[0161] A computer-readable storage medium is also provided in an embodiment of the present application. The computer-readable storage medium stores a computer program. The computer program includes program instructions. The processor executes the program instructions to implement the steps of the page resource acquisition method provided in the above embodiments of the present application.
[0162] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc., equipped on the computer device.
[0163] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A page resource acquisition method, characterized in that: include: Obtaining the client's page resources to be published and resource information corresponding to the page resources; Inputting the page resources into a preset automation script module, wherein the automation script module is used to aggregate the page resources into an offline compression package; Generate path information of the page resource corresponding to the offline compressed package according to the resource information; the path information at least includes identification information, version number and download link corresponding to the page resource; When the client publishes, the offline compressed package and the corresponding path information are added to the resource library corresponding to the client; When monitoring that the client receives a resource acquisition request, intercepting and parsing the resource acquisition request, and obtaining a request file identifier corresponding to the resource request; Matching the requested file identifier with each of the identification information in the resource library, and obtaining a version number and a download link corresponding to the successfully matched identification information; If it is determined that the version number is the latest version corresponding to the page resource, the offline compressed package is downloaded according to the download link, the offline compressed package is decompressed to obtain the page resource, and the response to the resource acquisition request is completed.
2. The method according to claim 1, characterized in that The page resources include at least web page content, images, style sheets and script files; Before inputting the page resource into the preset automation script module, it also includes: Determine the first target resource to be packaged in each of the page resources according to a preset compression rule; wherein the compression rule includes one or more of whether the resource type is a pending resource type, whether the file size is within a preset range, and whether the update time is within a preset time interval; The first target resource is input into a preset automation script module.
3. The method according to claim 2, characterized in that Before inputting the first target resource into a preset automation script module, the method further includes: Determine the page type corresponding to the page resource according to the resource information; Determine each of the page resources except the first target resource as a pending resource; Calculate the dependency relationship between each pending resource and the page type; A second target resource is determined from the pending resources according to the dependency relationship, so as to input the first target resource and the second target resource into a preset automation script module.
4. The method according to claim 1, characterized in that: The step of generating path information of page resources corresponding to the offline compressed package according to the resource information includes: Parsing the page resource to obtain a unique identifier of the page resource and the version number of the current version; generating the identification information according to the unique identifier; Generate a download link corresponding to the page resource, wherein the download link includes the storage path of the offline compressed package; The identification information, version number and download link are combined to generate the path information.
5. The method according to claim 1, characterized in that The adding the offline compressed package and the corresponding path information to the resource library corresponding to the client includes: Before the client publishes, the resource library structure corresponding to the client is obtained; the resource library structure includes the storage path of the resource library and the corresponding database; Storing the offline compressed package in the resource library; Generate index information according to the identification information, version number and download link of the page resource; The index file of the resource library is updated according to the index information; wherein the index file is used to retrieve the path information corresponding to the page resource in the storage path of the resource library.
6. The method according to claim 1, characterized in that If the request file identifier and each of the identifier information in the resource library fail to match, the method further includes: Downloading the page resource corresponding to the request file identifier from a preset online resource library to complete the response to the resource acquisition request; or, The interception of the resource acquisition request is canceled, and the client responds to the resource acquisition request to complete the online acquisition of the page resource corresponding to the request file identifier.
7. The method according to claim 1, characterized in that If it is determined that the version number is not the latest version corresponding to the page resource, the method further includes: generating a download request according to the identification information; Sending the download request to the cloud to receive the page resource returned by the cloud; The page resources in the offline compressed package are replaced according to the page resources returned by the cloud.
8. A page resource device, characterized in that: include: A resource acquisition unit, used to acquire the page resources of the client to be published and the resource information corresponding to the page resources; A resource input unit, used to input the page resources into a preset automation script module, and the automation script module is used to aggregate the page resources into an offline compression package; A path generation unit, configured to generate path information of the page resource corresponding to the offline compressed package according to the resource information; the path information at least includes identification information, version number and download link corresponding to the page resource; A path adding unit, used for adding the offline compressed package and the corresponding path information to the resource library corresponding to the client when the client publishes; A request monitoring unit, configured to intercept and parse the resource acquisition request when monitoring that the client receives the resource acquisition request, and obtain a request file identifier corresponding to the resource request; An identification matching unit, used to match the requested file identification with each identification information in the resource library, and obtain a version number and a download link corresponding to the successfully matched identification information; The request response unit is used to download the offline compressed package according to the download link if it is determined that the version number is the latest version corresponding to the page resource, decompress the offline compressed package to obtain the page resource, and complete the response to the resource acquisition request.
9. A computer device, characterized in that: The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is configured to execute the computer program and implement the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to implement the method according to any one of claims 1 to 7.