A method and apparatus for managing resource files

By storing shared resource files in a database and replacing them with local links, the problems of long interface loading times and network anomalies that caused interface display issues were resolved, resulting in faster loading speeds and reduced bandwidth usage.

CN115062253BActive Publication Date: 2025-10-21JINGDONG TECH HLDG CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210673826.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-15
Publication Date
2025-10-21
Estimated Expiration
2042-06-15

AI Technical Summary

Technical Problem

In existing technologies, the resource files generated by compiling the front-end code need to be obtained from CDN or the origin server, which results in long interface loading times and the interface failing to display when there is a network error.

Method used

When an external resource link is identified as a shared resource link, it is stored in the database and replaced with a local link on the terminal. A new resource package is generated, and shared resource files are cached locally in advance to reduce network dependence.

Benefits of technology

It shortens the interface loading time, avoids interface display problems caused by network anomalies, saves data traffic, and improves the opening speed of H5 pages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115062253B_ABST
    Figure CN115062253B_ABST
Patent Text Reader

Abstract

The application discloses a kind of methods and devices for managing resource files, and it relates to computer technical field.The specific embodiment of the method includes: obtaining the hypertext markup language file in resource package, read the label of external resource link introduced in the hypertext markup language file;Determine whether the external resource link is common resource link, if so, the common resource file corresponding to the external resource link is stored in database, and the external resource link is replaced by terminal local resource link;The private resource file corresponding to other external resource link and the hypertext markup language file after replacement link are regenerated new resource package.This embodiment can solve the technical problems that interface loading time is relatively long and interface cannot be displayed if network exception occurs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for managing resource files. Background Art

[0002] After the existing front-end code is compiled, it mainly generates HTML, Font, JS, CSS, Img and other files. These resource files will be deployed to the source site every time they go online. When the user accesses the interface link, it will query whether there is a cache record from the CDN (Content Distribution Network) node. If there is a record, it will be obtained from the CDN. If there is no record, it will be obtained from the source site and cached to the CDN.

[0003] If an H5 interface requires information from external resource files, it must be retrieved through a network request and cannot be executed until the resource files are downloaded. This requires the user to wait, and the interface loading process takes a long time. If a network anomaly occurs during the loading process, the interface will not display and will have to be forced to refresh. Summary of the Invention

[0004] In view of this, an embodiment of the present invention provides a method and apparatus for managing resource files to solve the technical problems of long interface loading time and interface failure to be displayed if network anomalies occur.

[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for managing resource files is provided, which is applied to a server and includes:

[0006] Obtaining a hypertext markup language file in a resource package, and reading a tag in the hypertext markup language file that introduces a link to an external resource;

[0007] Determine whether the external resource link is a shared resource link, and if so, store the shared resource file corresponding to the external resource link in a database, and replace the external resource link with a local resource link of the terminal;

[0008] The private resource files corresponding to other external resource links and the hypertext markup language files after the links are replaced are regenerated into a new resource package.

[0009] Optionally, storing the shared resource file corresponding to the external resource link in a database and replacing the external resource link with a local resource link of the terminal includes:

[0010] Determining whether a shared resource file corresponding to the external resource link has been stored in the database;

[0011] If so, replace the external resource link with the terminal's local resource link;

[0012] If not, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with a local resource link of the terminal.

[0013] Optionally, determining whether the shared resource file corresponding to the external resource link has been stored in the database includes:

[0014] Intercepting the external resource link in sections to obtain the type, version number, and name of the common resource file corresponding to the external resource link;

[0015] Based on the type, version number and name of the shared resource file, it is determined whether the shared resource file has been stored in the database.

[0016] Optionally, after regenerating a new resource package from the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced, the method further includes:

[0017] Generate a shared resource package from the shared resource files corresponding to each of the external resource links;

[0018] Storing the new resource bundle and the shared resource bundle in a first cache;

[0019] Storing the package information of the new resource package in the second cache; wherein the package information includes at least one of the following:

[0020] The correspondence between the terminal information that meets the offline download conditions and the resource package name, the resource package name, version number and download address, the name, version number and download address of the shared resource package, and the local resource link of the terminal.

[0021] Optionally, after storing the package information of the new resource package in the second cache, the method further includes:

[0022] Receiving a configuration read request sent by a terminal, wherein the configuration read request carries terminal information;

[0023] Determining whether the terminal information meets offline download conditions;

[0024] If so, the name, version number and download address of the corresponding resource package are returned to the terminal, including the name, version number and download address of the resource package and the local resource link of the terminal.

[0025] In addition, according to another aspect of an embodiment of the present invention, a method for managing resource files is provided, which is applied to a terminal and includes:

[0026] Send a configuration read request to the server, where the configuration read request carries terminal information;

[0027] Receive the resource package name, version number and download address returned by the server, including the resource package name, version number and download address, and the local resource link of the terminal;

[0028] Downloading the resource package and the shared resource package from a first cache according to the name, version number, and download address of the resource package and the name, version number, and download address of the shared resource package;

[0029] The shared resource package is stored in a directory corresponding to the local resource link of the terminal.

[0030] In addition, according to another aspect of an embodiment of the present invention, there is provided a device for managing resource files, which is provided on a server side and includes:

[0031] An acquisition module is used to acquire a hypertext markup language file in a resource package and read a tag in the hypertext markup language file that introduces a link to an external resource;

[0032] a replacement module, configured to determine whether the external resource link is a shared resource link, and if so, store the shared resource file corresponding to the external resource link in a database, and replace the external resource link with a local resource link of the terminal;

[0033] The generating module is used to regenerate a new resource package by using the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced.

[0034] Optionally, the replacement module is further configured to:

[0035] Determining whether a shared resource file corresponding to the external resource link has been stored in the database;

[0036] If so, replace the external resource link with the terminal's local resource link;

[0037] If not, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with a local resource link of the terminal.

[0038] Optionally, the replacement module is further configured to:

[0039] Intercepting the external resource link in sections to obtain the type, version number, and name of the common resource file corresponding to the external resource link;

[0040] Based on the type, version number and name of the shared resource file, it is determined whether the shared resource file has been stored in the database.

[0041] Optionally, the generating module is further configured to:

[0042] After regenerating a new resource package from the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced, generating a shared resource package from the shared resource files corresponding to each of the external resource links;

[0043] Storing the new resource bundle and the shared resource bundle in a first cache;

[0044] Storing the package information of the new resource package in the second cache; wherein the package information includes at least one of the following:

[0045] The correspondence between the terminal information that meets the offline download conditions and the resource package name, the resource package name, version number and download address, the name, version number and download address of the shared resource package, and the local resource link of the terminal.

[0046] Optionally, a request processing module is further included, configured to:

[0047] After storing the package information of the new resource package in the second cache, the method further includes:

[0048] Receiving a configuration read request sent by a terminal, wherein the configuration read request carries terminal information;

[0049] Determining whether the terminal information meets offline download conditions;

[0050] If so, the name, version number and download address of the corresponding resource package are returned to the terminal, including the name, version number and download address of the resource package and the local resource link of the terminal.

[0051] In addition, according to another aspect of an embodiment of the present invention, there is provided a device for managing resource files, which is provided in a terminal and includes:

[0052] A configuration reading module is used to send a configuration reading request to the server, wherein the configuration reading request carries terminal information;

[0053] A receiving module, configured to receive the name, version number, and download address of the resource package returned by the server, including the name, version number, and download address of the resource package and the local resource link of the terminal;

[0054] A download module, configured to download the resource package and the shared resource package from the first cache according to the name, version number and download address of the resource package and the name, version number and download address of the shared resource package;

[0055] The storage module is used to store the shared resource package in a directory corresponding to the local resource link of the terminal.

[0056] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, including:

[0057] one or more processors;

[0058] a storage device for storing one or more programs,

[0059] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.

[0060] According to another aspect of the embodiments of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in any one of the above embodiments is implemented.

[0061] According to another aspect of an embodiment of the present invention, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the method described in any one of the above embodiments is implemented.

[0062] One embodiment of the above invention has the following advantages or beneficial effects: because if the external resource link is a shared resource link, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with the local resource link of the terminal, and then the private resource files corresponding to other external resource links and the hypertext markup language file after the replacement link are used to regenerate a new resource package, the technical problems in the prior art that the interface loading takes a long time and the interface cannot be displayed if a network anomaly occurs are overcome. The embodiment of the present invention extracts the shared resource files commonly used by the front-end project, and the terminal can cache the shared resource files and resource packages locally in advance, and changes the introduction of resource files from network loading to obtaining local cached resources, thereby reducing the terminal's dependence on the network environment, saving traffic for users, and shortening the opening speed of H5; since the shared resource files and resource packages are downloaded in advance, the problem of network anomalies during the loading process can be avoided.

[0063] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work. Among them:

[0065] Figure 1 is a schematic diagram of the main process of a method for managing resource files according to one embodiment of the present invention;

[0066] Figure 2 is a schematic diagram of the main process of a method for managing resource files according to a reference embodiment of the present invention;

[0067] Figure 3 is a schematic diagram of the main process of a method for managing resource files according to another embodiment of the present invention;

[0068] Figure 4 is a schematic diagram of the main process of a method for managing resource files according to another reference embodiment of the present invention;

[0069] Figure 5 is a schematic diagram of main modules of an apparatus for managing resource files according to one embodiment of the present invention;

[0070] Figure 6 is a schematic diagram of main modules of an apparatus for managing resource files according to another embodiment of the present invention;

[0071] Figure 7 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;

[0072] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0073] The following description of exemplary embodiments of the present invention is made in conjunction with the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding. These details should be considered as merely exemplary. Therefore, it should be appreciated by those skilled in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0074] Figure 1 FIG. 1 is a schematic diagram of the main process of a method for managing resource files according to an embodiment of the present invention. As an embodiment of the present invention, Figure 1 As shown, the method for managing resource files is applied to the server and may include:

[0075] Step 101: Obtain a hypertext markup language file in a resource package, and read a tag in the hypertext markup language file that introduces an external resource link.

[0076] In an embodiment of the present invention, the resource file resource package may mainly include resource files such as HTML (Hypertext Markup Language file), Font, JS, CSS or Img, among which tags for external resource links are introduced in HTML, and these external resource links point to external resource files. External resource files refer to material files such as Font, JS, CSS or Img required for interface rendering.

[0077] After the developer uploads the resource package to the server, the server obtains the HTML file in the resource package and reads the tags in the HTML file that introduce external resource links.

[0078] Step 102 : determining whether the external resource link is a shared resource link; if so, storing the shared resource file corresponding to the external resource link in a database, and replacing the external resource link with a local resource link of the terminal.

[0079] It is possible to pre-define which are shared resource files, and the server determines whether each external resource link is a shared resource link one by one. If so, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with the local resource link of the terminal.

[0080] It should be noted that developers can pre-define common resource files and their corresponding common resource links, and then the remaining resource files in the resource package are all private resource files.

[0081] Optionally, the shared resource file corresponding to the external resource link is stored in a database, and the external resource link is replaced with a local resource link of the terminal, including: judging whether the shared resource file corresponding to the external resource link has been stored in the database; if so, replacing the external resource link with a local resource link of the terminal; if not, storing the shared resource file corresponding to the external resource link in the database, and replacing the external resource link with a local resource link of the terminal. The embodiment of the present invention screens each shared resource file in each resource package, and stores each shared resource file in a database, so that each resource package can share these shared resource files, which not only saves traffic for the user, but also reduces the local cache resources of the terminal. Moreover, the present application also replaces the external resource link in the HTML file with a local resource link of the terminal, so that after the terminal downloads the shared resource file, it can directly obtain the shared resource file according to the local resource link of the terminal.

[0082] Optionally, determining whether the shared resource file corresponding to the external resource link has been stored in the database includes: segmenting and intercepting the external resource link to obtain the type, version number and name of the shared resource file corresponding to the external resource link; and determining whether the shared resource file has been stored in the database based on the type, version number and name of the shared resource file. In order to accurately determine whether the shared resource file corresponding to the external resource link has been stored in the database and avoid duplicate storage, an embodiment of the present invention first segments and intercepts the external resource link to obtain the type, version number and name of the shared resource file corresponding to the external resource link. Taking https: / / m.bb.com / aaa / 2.0.3 / aad.js as an example, / aaa is the type of the shared resource file, / 2.0.3 is the version number of the shared resource file, and / aad.js is the name of the shared resource file. Therefore, based on the type, version number and name of the shared resource file, it can be accurately determined whether the shared resource file has been stored in the database. If the shared resource file has been stored in the database, the external resource link will be directly replaced with the local resource link of the terminal; if the shared resource file is not stored in the database, the shared resource file corresponding to the external resource link will be stored in the database, and the external resource link will be replaced with the local resource link of the terminal.

[0083] In order to improve the comparison speed, the type, version number and name of the common resource file stored in the database can also be entered into the common resource directory, so that it is convenient to quickly and accurately determine whether the common resource file has been stored in the database based on the type, version number and name of the common resource file.

[0084] Step 103: regenerate a new resource package by using the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced.

[0085] In the newly generated resource bundle, there are no shared resource files. This embodiment of the present invention stores all shared resource files in the database. In this step, the server regenerates a new resource bundle using the private resource files corresponding to the other external resource links and the HTML file after the links are replaced. It should be noted that all resource files other than the shared resource files are private resource files.

[0086] Optionally, after step 103, it also includes: generating a shared resource package from the shared resource files corresponding to each of the external resource links; storing the new resource package and the shared resource package in a first cache; storing the package information of the new resource package in a second cache; wherein the package information includes at least one of the following: the correspondence between the terminal information that meets the offline download conditions and the resource package name, the name, version number and download address of the resource package, the name, version number and download address of the shared resource package, and the local resource link of the terminal. After the embodiment of the present invention stores all the shared resource files in each resource package in the database, these shared resource files are packaged into a shared resource package, and then the shared resource package and the new resource package generated in step 103 are stored in the first cache for download by the terminal; at the same time, the package information of the new resource package is stored in the second cache for the terminal to obtain the name, version number and download address of the resource package, the name, version number and download address of the shared resource package, and the local resource link of the terminal. The embodiment of the present invention extracts the common resource files of the front-end project for caching, which are used by various projects in common, so that the terminal (i.e., the H5 terminal) can locally cache the shared resource files, reducing the terminal's dependence on the network environment, saving traffic for users, and shortening the opening speed of H5.

[0087] Optionally, after storing the package information of the new resource package in the second cache, the method further includes: receiving a configuration read request sent by a terminal, the configuration read request carrying terminal information; determining whether the terminal information meets the offline download conditions; and if so, returning the name, version number, and download address of the corresponding resource package, the name, version number, and download address of the shared resource package, and the local resource link of the terminal to the terminal. The terminal information may include the system version, APP version, user login name, etc. The server determines whether the terminal meets the offline download conditions based on the terminal information carried in the configuration read request. If so, the server returns the name, version number, and download address of the corresponding resource package, the name, version number, and download address of the shared resource package, and the local resource link of the terminal to the terminal. After receiving the name, version number, and download address of the resource package, the name, version number, and download address of the shared resource package, and the local resource link of the terminal, the terminal downloads the resource package and the shared resource package from the first cache based on the name, version number, and download address of the resource package and the name, version number, and download address of the shared resource package, and then stores the shared resource package in the directory corresponding to the local resource link of the terminal.

[0088] According to the various embodiments described above, it can be seen that the embodiment of the present invention solves the technical problems in the prior art that the interface loading takes a long time and the interface cannot be displayed if a network anomaly occurs by storing the shared resource files corresponding to the external resource link in the database if the external resource link is a shared resource link, replacing the external resource link with a local resource link of the terminal, and then regenerating a new resource package with the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced. The embodiment of the present invention extracts the shared resource files commonly used by the front-end project, and the terminal can cache the shared resource files and resource packages locally in advance, and change the introduction of resource files from network loading to obtaining local cached resources, thereby reducing the terminal's dependence on the network environment, saving traffic for users, and shortening the opening speed of H5; since the shared resource files and resource packages are downloaded in advance, the problem of network anomalies during the loading process can be avoided.

[0089] Figure 2 Schematic diagram of the main process of a method for managing resource files according to a reference embodiment of the present invention. As another embodiment of the present invention, Figure 2 As shown, the method for managing resource files is applied to the server and may include:

[0090] Step 201: Obtain a hypertext markup language file in a resource package, and read a tag in the hypertext markup language file that introduces an external resource link.

[0091] Step 202 , determining whether the external resource link is a shared resource link; if so, executing step 203 ; if not, ending.

[0092] The server determines whether each external resource link is a shared resource link one by one. Developers can pre-define shared resource files and their corresponding shared resource links, and then the remaining resource files in the resource package are private resource files.

[0093] Step 203: intercept the external resource link in sections to obtain the type, version number and name of the common resource file corresponding to the external resource link.

[0094] Step 204 , based on the type, version number and name of the shared resource file, determine whether the shared resource file has been stored in the database; if so, execute step 206 ; if not, execute step 205 .

[0095] In order to accurately determine whether the shared resource files corresponding to the external resource links have been stored in the database and avoid duplicate storage, the external resource links are first segmented to obtain the type, version number and name of the shared resource files corresponding to the external resource links, and then compared one by one with the type, version number and name of the shared resource files in the shared resource directory to determine whether the shared resource files are stored in the database.

[0096] Step 205: Store the shared resource file corresponding to the external resource link in the database.

[0097] If the type, version number and name of the same shared resource file are not matched in the shared resource directory, it means that the shared resource file has not been stored in the database. Then the shared resource file is stored in the database for sharing resource files among various projects.

[0098] Step 206: Replace the external resource link with a local resource link of the terminal.

[0099] If the shared resource file has been stored in the database, the external resource link is directly replaced with the terminal's local resource link, so that after the terminal downloads the shared resource file, it can directly obtain the shared resource file according to the terminal's local resource link.

[0100] Step 207 : regenerate a new resource package from the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced, and regenerate a shared resource package from each shared resource file.

[0101] Step 208: Store the new resource bundle and the shared resource bundle in a first cache, and store the bundle information of the new resource bundle in a second cache.

[0102] The package information includes at least one of the following: the correspondence between the terminal information that meets the offline download conditions and the resource package name, the resource package name, version number and download address, the shared resource package name, version number and download address, and the terminal local resource link.

[0103] After storing all the common resource files in each resource package in the database, the embodiment of the present invention packages these common resource files into a common resource package, and then stores the common resource package and the new resource package in the first cache for the terminal to download; at the same time, the package information of the new resource package is stored in the second cache, so that the terminal can obtain the name, version number and download address of the resource package, the name, version number and download address of the common resource package, and the local resource link of the terminal.

[0104] After step 208, the server receives a configuration read request sent by the terminal. The configuration read request carries terminal information, which may include system version, APP version, user login name, etc. The server determines whether the terminal meets the offline download conditions based on the terminal information carried in the configuration read request. If it meets the conditions, the server returns the name, version number and download address of the corresponding resource package, the name, version number and download address of the shared resource package, and the local resource link of the terminal to the terminal. After the terminal receives the name, version number and download address of the resource package, the name, version number and download address of the shared resource package, and the local resource link of the terminal, it downloads the resource package and the shared resource package from the first cache based on the name, version number and download address of the resource package and the name, version number and download address of the shared resource package, and then stores the shared resource package in the directory corresponding to the local resource link of the terminal.

[0105] In addition, the specific implementation content of the method for managing resource files in a reference embodiment of the present invention has been described in detail in the above-mentioned method for managing resource files, so the repeated content will not be described again here.

[0106] Figure 3 Schematic diagram of the main process of the method for managing resource files according to another embodiment of the present invention. As another embodiment of the present invention, Figure 3 As shown, the method for managing resource files is applied to a terminal and may include:

[0107] Step 301: Send a configuration read request to a server, where the configuration read request carries terminal information.

[0108] The terminal sends a configuration acquisition request to the server. The configuration read request carries terminal information, which may include system version, APP version, user login name, etc.

[0109] Step 302: Receive the name, version number, and download address of the resource package returned by the server, including the name, version number, and download address of the resource package and the local resource link of the terminal.

[0110] After receiving the configuration acquisition request, the server parses it to obtain the terminal information, and then determines whether the terminal meets the offline download conditions. If so, it returns the resource package name, version number and download address to the terminal, including the resource package name, version number and download address, as well as the local resource link of the terminal.

[0111] Step 303 : Download the resource package and the shared resource package from the first cache according to the name, version number, and download address of the resource package and the name, version number, and download address of the shared resource package.

[0112] The terminal downloads the resource package and the shared resource package from the first cache according to the name, version number and download address of the resource package returned by the server and the name, version number and download address of the shared resource package.

[0113] Step 304: Store the shared resource package in the directory corresponding to the local resource link of the terminal.

[0114] The terminal stores the shared resource package in the directory corresponding to the resource link based on the terminal local resource link returned by the server.

[0115] In an embodiment of the present invention, the server extracts the common resource files commonly used by the front-end project, and the terminal can download the common resource files and resource packages offline to the local in advance, and change the introduction of resource files from network loading to obtaining local cache resources, thereby reducing the terminal's dependence on the network environment, saving traffic for users, and shortening the opening speed of H5; since the common resource files and resource packages are downloaded in advance, network anomalies during the loading process can be avoided.

[0116] Figure 4 Schematic diagram of the main process of the method for managing resource files according to another reference embodiment of the present invention. As another embodiment of the present invention, Figure 4 As shown, the method for managing resource files may include:

[0117] In step ①, after the developer compiles and packages the code, they upload the resource package to the offline platform and configure various information. The configured information may include the username of the user who uploaded the resource package, the upload time, the size of the resource package, the editing permissions of the resource package, the testing permissions of the resource package, whether to strip shared resources, etc. It may also include the terminal information corresponding to the resource package that meets the offline download conditions (which terminals the offline function is targeted at, and grayscale functions are implemented for different groups of people).

[0118] In steps ② and ③, the offline platform manages the resource package through the Nodejs service. Specifically, the Nodejs service obtains the hypertext markup language file in the resource package, reads the tag that introduces the external resource link in the hypertext markup language file, and determines whether the external resource link is a shared resource link. If so, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with the terminal's local resource link. The private resource files corresponding to other external resource links and the replaced hypertext markup language file are then regenerated into a new resource package. The Nodejs service also generates a shared resource package from the shared resource files corresponding to each external resource link.

[0119] Furthermore, the Nodejs service stores the package information of the new resource package in a MySQL database and synchronizes it to the Redis cache; wherein, the package information includes at least one of the following: the correspondence between the terminal information that meets the offline download conditions and the resource package name, the name, version number and download address of the resource package, the name, version number and download address of the shared resource package, and the local resource link of the terminal.

[0120] Step 4: Upload the new resource package and the shared resource package to the JSS service for caching through the Nodejs service, and publish the new resource package and the shared resource package to the WebServer server for the updated back-to-source operation.

[0121] Step 5: When the terminal user opens the APP, the Java gateway interface is called first. The input parameters of the calling interface are terminal information (including system version, APP version, user login name, etc.).

[0122] Step ⑥, the Java gateway interface reads the terminal information that meets the offline download conditions from the Redis cache, and determines whether the terminal meets the offline download conditions. If so, it returns the name, version number and download address of the corresponding resource package to the terminal, including the name, version number and download address of the resource package and the local resource link of the terminal.

[0123] It should be noted that an app may contain multiple resource packages. The app calls the Java gateway interface to obtain which resource packages to download and the shared resource packages, as well as the names, version numbers, and download addresses of these resource packages. Due to the grayscale policy, the resource packages downloaded by each terminal may be different (the grayscale policy can be implemented by configuring it on the offline platform).

[0124] Step 7: The terminal requests the JSS server to download an offline package, including multiple resource packages and a common resource package.

[0125] In step ⑧, the JSS server sends the multiple resource packages requested by the terminal and a shared resource package to the terminal. The terminal caches the multiple resource packages and the shared resource package locally, where the shared resource package is stored in the directory corresponding to the resource link of the local terminal.

[0126] Therefore, when the user opens the corresponding interface, the local cache file can be directly loaded to increase the opening speed, allowing the user to open the H5 interface in weak or no network conditions.

[0127] Figure 5 FIG. 1 is a schematic diagram of the main modules of a device for managing resource files according to an embodiment of the present invention. Figure 5As shown, the device 500 for managing resource files includes an acquisition module 501, a replacement module 502 and a generation module 503; wherein, the acquisition module 501 is used to acquire the hypertext markup language file in the resource package, and read the tag that introduces the external resource link in the hypertext markup language file; the replacement module 502 is used to determine whether the external resource link is a shared resource link. If so, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with a local resource link of the terminal; the generation module 503 is used to regenerate a new resource package with the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced.

[0128] Optionally, the replacement module 502 is further configured to:

[0129] Determining whether a shared resource file corresponding to the external resource link has been stored in the database;

[0130] If so, replace the external resource link with the terminal's local resource link;

[0131] If not, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with a local resource link of the terminal.

[0132] Optionally, the replacement module 502 is further configured to:

[0133] Intercepting the external resource link in sections to obtain the type, version number, and name of the common resource file corresponding to the external resource link;

[0134] Based on the type, version number and name of the shared resource file, it is determined whether the shared resource file has been stored in the database.

[0135] Optionally, the generating module 503 is further configured to:

[0136] After regenerating a new resource package from the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced, generating a shared resource package from the shared resource files corresponding to each of the external resource links;

[0137] Storing the new resource bundle and the shared resource bundle in a first cache;

[0138] Storing the package information of the new resource package in the second cache; wherein the package information includes at least one of the following:

[0139] The correspondence between the terminal information that meets the offline download conditions and the resource package name, the resource package name, version number and download address, the name, version number and download address of the shared resource package, and the local resource link of the terminal.

[0140] Optionally, a request processing module is further included, configured to:

[0141] After storing the package information of the new resource package in the second cache, the method further includes:

[0142] Receiving a configuration read request sent by a terminal, wherein the configuration read request carries terminal information;

[0143] Determining whether the terminal information meets offline download conditions;

[0144] If so, the name, version number and download address of the corresponding resource package are returned to the terminal, including the name, version number and download address of the resource package and the local resource link of the terminal.

[0145] It should be noted that the specific implementation content of the device for managing resource files in the present invention has been described in detail in the method for managing resource files described above, so the details will not be repeated here.

[0146] Figure 6 FIG. 1 is a schematic diagram of the main modules of an apparatus for managing resource files according to another embodiment of the present invention. Figure 6 As shown, the device 600 for managing resource files includes a configuration reading module 601, a receiving module 602, a downloading module 603 and a storage module 604; wherein, the configuration reading module 601 is used to send a configuration reading request to the server, and the configuration reading request carries terminal information; the receiving module 602 is used to receive the name, version number and download address of the resource package returned by the server, the name, version number and download address of the shared resource package, and the local resource link of the terminal; the downloading module 603 is used to download the resource package and the shared resource package from the first cache according to the name, version number and download address of the resource package and the name, version number and download address of the shared resource package; the storage module 604 is used to store the shared resource package in the directory corresponding to the local resource link of the terminal.

[0147] It should be noted that the specific implementation content of the device for managing resource files in the present invention has been described in detail in the method for managing resource files described above, so the details will not be repeated here.

[0148] Figure 7 An exemplary system architecture 700 is shown to which the method or apparatus for managing resource files according to an embodiment of the present invention may be applied.

[0149] like Figure 7 As shown, system architecture 700 may include terminal devices 701, 702, 703, a network 704, and a server 705. Network 704 is used to provide a medium for communication links between terminal devices 701, 702, 703 and server 705. Network 704 may include various connection types, such as wired or wireless communication links or fiber optic cables.

[0150] Users can use terminal devices 701, 702, and 703 to interact with server 705 via network 704 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 701, 702, and 703, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0151] The terminal devices 701 , 702 , and 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0152] Server 705 may be a server that provides various services, such as a backend management server (for example only) that supports shopping websites browsed by users using terminal devices 701, 702, and 703. The backend management server may analyze and process received data such as item information query requests, and feed back the processing results to the terminal device.

[0153] It should be noted that the method for managing resource files provided in the embodiment of the present invention is generally executed by the server 705, and accordingly, the apparatus for managing resource files is generally disposed in the server 705. The method for managing resource files provided in the embodiment of the present invention may also be executed by the terminal devices 701, 702, and 703, and accordingly, the apparatus for managing resource files may be disposed in the terminal devices 701, 702, and 703.

[0154] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0155] Reference below Figure 8 , which shows a schematic structural diagram of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0156] like Figure 8As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage unit 808 into a random access memory (RAM) 803. Various programs and data required for the operation of the system 800 are also stored in the RAM 803. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0157] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, and the like; an output section 807 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 808 including a hard disk; and a communication section 809 including a network interface card such as a LAN card or a modem. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 810 as needed, so that computer programs read therefrom can be installed into the storage section 808 as needed.

[0158] In particular, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 809, and / or installed from a removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.

[0159] It should be noted that the computer-readable medium described in the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.

[0160] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer programs according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0161] The modules described in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be provided in a processor. For example, a processor may be described as including an acquisition module, a replacement module, and a generation module. The names of these modules do not, in some cases, limit the modules themselves.

[0162] The modules described in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be provided in a processor. For example, a processor may be described as including a configuration reading module, a receiving module, a downloading module, and a storage module. The names of these modules do not, in some cases, limit the modules themselves.

[0163] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently and not be assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device implements the following method: obtaining a hypertext markup language file in a resource package, reading a tag that introduces an external resource link in the hypertext markup language file; determining whether the external resource link is a shared resource link, and if so, storing the shared resource file corresponding to the external resource link in a database, and replacing the external resource link with a local resource link of the terminal; and regenerating a new resource package using the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced.

[0164] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently and not be incorporated into the device. The computer-readable medium carries one or more programs. When the one or more programs are executed by a device, the device implements the following method: sending a configuration read request to a server, wherein the configuration read request carries terminal information;

[0165] Receive the resource package name, version number and download address returned by the server, including the resource package name, version number and download address, and the local resource link of the terminal;

[0166] Downloading the resource package and the shared resource package from a first cache according to the name, version number, and download address of the resource package and the name, version number, and download address of the shared resource package;

[0167] The shared resource package is stored in a directory corresponding to the local resource link of the terminal.

[0168] As another aspect, an embodiment of the present invention further provides a computer program product, including a computer program, which implements the method described in any of the above embodiments when executed by a processor.

[0169] According to the technical solution of the embodiment of the present invention, if the external resource link is a shared resource link, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with the local resource link of the terminal, and then the private resource files corresponding to other external resource links and the hypertext markup language file after the replacement link are used to regenerate a new resource package. Therefore, the technical problems in the prior art that the interface loading takes a long time and the interface cannot be displayed if a network anomaly occurs are overcome. The embodiment of the present invention extracts the shared resource files commonly used by the front-end project, and the terminal can cache the shared resource files and resource packages locally in advance, and changes the introduction of resource files from network loading to obtaining local cached resources, thereby reducing the terminal's dependence on the network environment, saving traffic for users, and shortening the opening speed of H5; since the shared resource files and resource packages are downloaded in advance, the problem of network anomalies during the loading process can be avoided.

[0170] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A method for managing resource files, characterized in that: Applied to the server, including: Obtaining a hypertext markup language file in a resource package, and reading a tag in the hypertext markup language file that introduces a link to an external resource; Determine whether the external resource link is a shared resource link. If so, store the shared resource file corresponding to the external resource link in a database and replace the external resource link with a local resource link of the terminal; each resource package shares the shared resource file in the database; Regenerate a new resource package by using the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced; Storing the shared resource file corresponding to the external resource link in a database, and replacing the external resource link with a local resource link of the terminal, including: Intercepting the external resource link in sections to obtain the type, version number, and name of the shared resource file corresponding to the external resource link; and determining whether the shared resource file has been stored in a database based on the type, version number, and name of the shared resource file; If so, replace the external resource link with the terminal's local resource link; If not, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with a local resource link of the terminal.

2. The method according to claim 1, characterized in that After regenerating a new resource package from the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced, the method further includes: Generate a shared resource package from the shared resource files corresponding to each of the external resource links; Storing the new resource bundle and the shared resource bundle in a first cache; Storing the package information of the new resource package in the second cache; wherein the package information includes at least one of the following: The correspondence between the terminal information that meets the offline download conditions and the resource package name, the resource package name, version number and download address, the name, version number and download address of the shared resource package, and the local resource link of the terminal.

3. The method according to claim 2, characterized in that After storing the package information of the new resource package in the second cache, the method further includes: Receiving a configuration read request sent by a terminal, wherein the configuration read request carries terminal information; Determining whether the terminal information meets offline download conditions; If so, the name, version number and download address of the corresponding resource package are returned to the terminal, including the name, version number and download address of the resource package and the local resource link of the terminal.

4. A method for managing resource files, characterized in that: Applied to terminals, including: Send a configuration read request to the server, where the configuration read request carries terminal information; Receive the resource package name, version number and download address returned by the server, including the resource package name, version number and download address, and the local resource link of the terminal; The resource package and the shared resource package are downloaded from the first cache according to the name, version number and download address of the resource package and the name, version number and download address of the shared resource package; the shared resource package is generated by the shared resource files corresponding to each external resource link, and the resource package is generated by the following steps: obtaining a hypertext markup language file in the resource package, reading a tag that introduces an external resource link in the hypertext markup language file; determining whether the external resource link is a shared resource link, and if so, storing the shared resource file corresponding to the external resource link in a database, and replacing the external resource link with a local resource link of the terminal; each resource package shares the shared resource file in the database; regenerating a new resource package by using the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced; Storing the shared resource package in the directory corresponding to the local resource link of the terminal; Storing the shared resource file corresponding to the external resource link in a database, and replacing the external resource link with a local resource link of the terminal, including: Intercepting the external resource link in sections to obtain the type, version number, and name of the shared resource file corresponding to the external resource link; and determining whether the shared resource file has been stored in a database based on the type, version number, and name of the shared resource file; If so, replace the external resource link with the terminal's local resource link; If not, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with a local resource link of the terminal.

5. A device for managing resource files, characterized in that: Set on the server, including: An acquisition module is used to acquire a hypertext markup language file in a resource package and read a tag in the hypertext markup language file that introduces a link to an external resource; a replacement module, configured to determine whether the external resource link is a shared resource link; if so, store the shared resource file corresponding to the external resource link in a database, and replace the external resource link with a local resource link of the terminal; each resource package shares the shared resource file in the database; A generating module, configured to regenerate a new resource package from the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced; The replacement module is further configured to: Intercepting the external resource link in sections to obtain the type, version number, and name of the shared resource file corresponding to the external resource link; and determining whether the shared resource file has been stored in a database based on the type, version number, and name of the shared resource file; If so, replace the external resource link with the terminal's local resource link; If not, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with a local resource link of the terminal.

6. A device for managing resource files, characterized in that: Set on the terminal, including: A configuration reading module is used to send a configuration reading request to the server, wherein the configuration reading request carries terminal information; A receiving module, configured to receive the name, version number, and download address of the resource package returned by the server, including the name, version number, and download address of the resource package and the local resource link of the terminal; A download module is used to download the resource package and the shared resource package from the first cache according to the name, version number and download address of the resource package and the name, version number and download address of the shared resource package; the shared resource package is generated by the shared resource files corresponding to each external resource link, and the resource package is generated by the following steps: obtaining a hypertext markup language file in the resource package, reading a tag that introduces an external resource link in the hypertext markup language file; determining whether the external resource link is a shared resource link, and if so, storing the shared resource file corresponding to the external resource link in a database, and replacing the external resource link with a local resource link of the terminal; each resource package shares the shared resource file in the database; and regenerating a new resource package by using the private resource files corresponding to other external resource links and the hypertext markup language file after the link is replaced; A storage module, configured to store the shared resource package in a directory corresponding to a local resource link of the terminal; Storing the shared resource file corresponding to the external resource link in a database, and replacing the external resource link with a local resource link of the terminal, including: Intercepting the external resource link in sections to obtain the type, version number, and name of the shared resource file corresponding to the external resource link; and determining whether the shared resource file has been stored in a database based on the type, version number, and name of the shared resource file; If so, replace the external resource link with the terminal's local resource link; If not, the shared resource file corresponding to the external resource link is stored in the database, and the external resource link is replaced with a local resource link of the terminal.

7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.

8. A computer-readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

9. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Method and device for accelerating webpage opening speed, medium and electronic equipment

    CN110471709A

  • Method and system for accelerated content download over a data network

    WO2002010905A2