CN110866198A - Static resource caching method, system, device, computer equipment and storage medium - Google Patents
Static resource caching method, system, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN110866198A CN110866198A CN201910924847.1A CN201910924847A CN110866198A CN 110866198 A CN110866198 A CN 110866198A CN 201910924847 A CN201910924847 A CN 201910924847A CN 110866198 A CN110866198 A CN 110866198A
- Authority
- CN
- China
- Prior art keywords
- resource
- hash value
- static resource
- static
- information list
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/957—Browsing optimisation, e.g. caching or content distillation
- G06F16/9574—Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Between Computers (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application relates to a static resource caching method, a system, a device, computer equipment and a storage medium. The method comprises the following steps: acquiring a starting instruction of an application program; requesting a current resource information list from an interface server according to a starting instruction, wherein the current resource information list has a corresponding current list version hash value; acquiring an initial resource information list of local cache, and determining a static resource path to be updated according to the current resource information list and the initial resource information list when the hash value of the current list version is inconsistent with the hash value of the initial list version; sending the static resource path to be updated to a static resource server through a resource loading request, and receiving a target static resource returned by the static resource server; performing hash value calculation on the target static resource to obtain a hash value of the target resource; and when the hash value of the target resource is consistent with the corresponding hash value of the current resource, caching the target static resource. By adopting the method, the updating efficiency of the static resources can be improved.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, a system, an apparatus, a computer device, and a storage medium for caching static resources.
Background
With the development of technologies, more and more intelligent devices, such as smart phones, tablet computers, smart televisions and the like, have come into the lives of people. Among other things, users can load various applications in smart devices to implement various different functions. When the smart device runs an application program, it is often necessary to acquire static resources capable of rendering a page, for example, a picture, a JS file, a CSS file, and the like. In order to accelerate the rendering speed of the page and improve the rendering efficiency, the smart device usually needs to store the static resource locally, so that the locally stored static resource is directly loaded when the page is rendered.
However, the static resources in the server often need to be updated, and when the application program needs to perform page rendering through the static resources of the latest version, the smart device may send a resource acquisition request to the server, and all the static resources corresponding to the application program need to be downloaded again, which easily results in low update efficiency of the static resources.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a static resource caching method, system, apparatus, computer device and storage medium capable of improving the static resource updating efficiency.
A method of static resource caching, the method comprising:
acquiring a starting instruction of the application program, wherein the starting instruction is used for indicating the starting of the application program;
requesting a current resource information list from an interface server according to a starting instruction, wherein the current resource information list has a corresponding current list version hash value, and the current resource information list comprises a static resource identifier, a static resource path corresponding to the static resource identifier and a current resource hash value corresponding to the static resource identifier;
acquiring an initial resource information list of local cache, and determining a static resource path to be updated corresponding to a static resource identifier to be updated in a current resource information list according to the current resource information list and the initial resource information list when the hash value of the version of the current list is inconsistent with the hash value of the version of the initial list corresponding to the initial resource information list;
sending the static resource path to be updated to a static resource server through a resource loading request, wherein the resource loading request is used for indicating the static resource server to obtain and return the corresponding target static resource according to the static resource path to be updated;
performing hash value calculation on the returned target static resource to obtain a corresponding hash value of the target resource;
and when the hash value of the target resource is consistent with the corresponding hash value of the current resource, caching the target static resource.
In one embodiment, the static resource caching method further includes: and requesting a webpage running file from the rendering server according to the starting instruction, wherein the webpage running file is obtained by the rendering server through virtual tree construction according to the webpage code file, acquiring the webpage running static resource required by the webpage running file from the cached static resource, executing the webpage running file according to the webpage running static resource, and rendering to obtain the target webpage.
In one embodiment, the static resource caching method further includes: intercepting a request for loading an application program webpage, analyzing the request, determining a resource hash value of a static resource specified by the request, splicing a locally cached static resource path according to the resource hash value of the static resource specified by the request, and if the static resource path is invalid, sending a static resource acquisition request to a static resource server so that the static resource server returns a corresponding first static resource according to the static resource acquisition request, and receiving and caching the first static resource.
In one embodiment, the static resource caching method further includes: the method comprises the steps of obtaining a project source code corresponding to an application program, constructing the project source code by using a resource packaging program to obtain a resource information list, a webpage running file and static resources, deploying the resource information list into an interface server, deploying the webpage running file into a rendering server, deploying the static resources into a static resource server, wherein the resource information list comprises a static resource path corresponding to the static resource server from the static resources.
In one embodiment, when the hash value of the current list version is inconsistent with the hash value of the initial list version corresponding to the initial resource information list, determining a static resource path to be updated corresponding to a static resource identifier to be updated in the current resource information list according to the current resource information list and the initial resource information list, includes: the method comprises the steps of obtaining an initial list version hash value corresponding to an initial resource information list, obtaining a first resource hash value when the initial list version hash value is inconsistent with a current list version hash value, obtaining a second resource hash value when the first resource hash value is a resource hash value of a first static resource identifier corresponding to the current resource information list, obtaining a second resource hash value when the second resource hash value is a resource hash value of the first static resource identifier corresponding to the initial resource information list, determining the first static resource identifier as a static resource identifier to be updated when the first resource hash value is inconsistent with the second resource hash value, and determining a first static resource path corresponding to the first static resource identifier as a static resource path to be updated.
In one embodiment, the performing hash value calculation on the returned target static resource to obtain a corresponding hash value of the target resource includes: and acquiring a hash value algorithm, and calculating the hash value of the target static resource according to the hash value algorithm to obtain the corresponding hash value of the target resource.
A static resource caching system, the system comprising:
the terminal is used for acquiring a starting instruction of the application program, wherein the starting instruction is used for indicating the starting of the application program and sending the starting instruction to the interface server;
the interface server is used for receiving a starting instruction, requesting a current resource information list according to the starting instruction, wherein the current resource information list has a corresponding current list version hash value, and comprises a static resource identifier, a static resource path corresponding to the static resource identifier and a current resource hash value corresponding to the static resource identifier;
the terminal is used for receiving the current resource information list, acquiring a locally cached initial resource information list, determining a static resource path to be updated corresponding to a static resource identifier to be updated in the current resource information list according to the current resource information list and the initial resource information list when the hash value of the version of the current list is inconsistent with the hash value of the version of the initial list corresponding to the initial resource information list, and sending the static resource path to be updated to the static resource server through a resource loading request;
the static resource server is used for receiving the resource loading request, loading according to a static resource path to be updated in the resource loading request and returning the corresponding target static resource to the terminal;
and the terminal is used for receiving the returned target static resource, calculating the hash value of the target static resource to obtain the corresponding hash value of the target resource, and caching the target static resource when the hash value of the target resource is consistent with the corresponding hash value of the current resource.
In one embodiment, the terminal is further configured to: sending a starting instruction to a rendering server; the rendering server is used for receiving the starting instruction, acquiring a webpage code file according to the starting instruction, constructing a virtual tree according to the webpage code file to obtain a webpage running file, and returning the webpage running file to the terminal; and the terminal is also used for acquiring the webpage running static resource required by the webpage running file from the cached static resource, executing the webpage running file according to the webpage running static resource and rendering to obtain the target webpage.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
acquiring a starting instruction of the application program, wherein the starting instruction is used for indicating the starting of the application program;
requesting a current resource information list from an interface server according to a starting instruction, wherein the current resource information list has a corresponding current list version hash value, and the current resource information list comprises a static resource identifier, a static resource path corresponding to the static resource identifier and a current resource hash value corresponding to the static resource identifier;
acquiring an initial resource information list of local cache, and determining a static resource path to be updated corresponding to a static resource identifier to be updated in a current resource information list according to the current resource information list and the initial resource information list when the hash value of the version of the current list is inconsistent with the hash value of the version of the initial list corresponding to the initial resource information list;
sending the static resource path to be updated to a static resource server through a resource loading request, wherein the resource loading request is used for indicating the static resource server to obtain and return the corresponding target static resource according to the static resource path to be updated;
performing hash value calculation on the returned target static resource to obtain a corresponding hash value of the target resource;
and when the hash value of the target resource is consistent with the corresponding hash value of the current resource, caching the target static resource.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
acquiring a starting instruction of the application program, wherein the starting instruction is used for indicating the starting of the application program;
requesting a current resource information list from an interface server according to a starting instruction, wherein the current resource information list has a corresponding current list version hash value, and the current resource information list comprises a static resource identifier, a static resource path corresponding to the static resource identifier and a current resource hash value corresponding to the static resource identifier;
acquiring an initial resource information list of local cache, and determining a static resource path to be updated corresponding to a static resource identifier to be updated in a current resource information list according to the current resource information list and the initial resource information list when the hash value of the version of the current list is inconsistent with the hash value of the version of the initial list corresponding to the initial resource information list;
sending the static resource path to be updated to a static resource server through a resource loading request, wherein the resource loading request is used for indicating the static resource server to obtain and return the corresponding target static resource according to the static resource path to be updated;
performing hash value calculation on the returned target static resource to obtain a corresponding hash value of the target resource;
and when the hash value of the target resource is consistent with the corresponding hash value of the current resource, caching the target static resource.
After an application program is started, a current resource information list is requested from an interface server, the current resource information list is compared with an initial resource information list cached locally to obtain a static resource identifier to be updated, which is changed only in the current resource information list, a corresponding target static resource is obtained from the static resource server according to a static resource path to be updated corresponding to the static resource identifier to be updated in the current resource information list, hash value calculation is carried out on the target static resource to obtain a hash value of the target resource, and when the hash value of the target resource is consistent with the hash value of the corresponding current resource, the target static resource is cached. Therefore, when the application program needs to pass through the static resource of the latest version or update the locally cached static resource, all the static resources corresponding to the application program do not need to be downloaded again, and only the changed static resource needs to be updated, so that the flow of the user is reduced, and the bandwidth and the pressure of the service are also saved.
Drawings
FIG. 1 is a diagram of an application environment of a static resource caching method in one embodiment;
FIG. 2 is a flow diagram illustrating a method for caching static resources according to an embodiment;
FIG. 3 is a flowchart illustrating a static resource caching method according to another embodiment;
FIG. 4 is a flowchart illustrating a static resource caching method according to another embodiment;
FIG. 5 is a flowchart illustrating a static resource caching method according to yet another embodiment;
FIG. 6 is a flowchart illustrating the step of determining a path of a static resource to be updated according to an embodiment;
FIG. 7 is a flowchart illustrating the hash value calculation of a target resource in one embodiment;
FIG. 8 is a block diagram of a static resource cache system in accordance with one embodiment;
FIG. 9 is a block diagram of a static resource cache system in another embodiment;
FIG. 10 is a block diagram of an embodiment of a static resource cache;
FIG. 11 is a diagram illustrating an internal structure of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The static resource caching method provided by the application can be applied to the application environment shown in fig. 1. Wherein the terminal 102 communicates with the interface server 104 via a network, the terminal 102 communicates with the static resource server 106 via a network, and the terminal 102 communicates with the rendering server 108 via a network. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the interface server 104, the static resource server 106, and the rendering server 108 may be implemented by independent servers or a server cluster formed by a plurality of servers.
Specifically, the terminal 102 is installed with a relevant application program, and may trigger generation of a start instruction through the relevant application program, where the start instruction is used to instruct starting of the application program, and may send the start instruction to the interface server 104 and the rendering server 108. After receiving the start instruction, the interface server 104 obtains a current resource information list according to the start instruction, where the current resource information list has a corresponding current list version hash value, and the current resource information list includes a static resource identifier, a static resource path corresponding to the static resource identifier, and a current resource hash value corresponding to the static resource identifier, and returns the current resource information list to the terminal 102.
Further, the terminal 102 obtains the initial resource information list cached locally, determines a static resource path to be updated corresponding to the static resource identifier to be updated in the current resource information list according to the current resource information list and the initial resource information list when the hash value of the version of the current list is inconsistent with the hash value of the version of the initial list corresponding to the initial resource information list, and sends the static resource path to be updated to the static resource server 106 through the resource loading request. After receiving the resource loading request, the static resource server 106 obtains and returns the corresponding target static resource to the terminal 102 according to the path of the static resource to be updated.
Finally, the terminal 102 calculates the hash value of the returned target static resource to obtain the corresponding hash value of the target resource. And when the hash value of the target resource is consistent with the corresponding hash value of the current resource, caching the target static resource.
After receiving the start instruction, the rendering server 108 obtains the webpage code file according to the start instruction, performs virtual tree construction on the webpage code file to obtain a webpage running file, and returns the webpage running file to the terminal 102. After receiving the webpage running file, the terminal 102 acquires the webpage running static resource required by the webpage running file from the cached static resource, executes the webpage running file according to the webpage running static resource, and renders to obtain the target webpage.
In an embodiment, as shown in fig. 2, a static resource caching method is provided, which is described by taking the application of the method to the terminal in fig. 1 as an example, and includes the following steps:
The application program is a computer program developed and run on an operating system for completing a certain task or certain specific tasks, a webpage is arranged on the application program, and a target webpage can be accessed by starting the application program. And after the rendering is finished, displaying the target webpage.
And the start instruction is used to instruct the application to start. The starting instruction can be generated by clicking a relevant button of the application program to trigger, or can be generated by performing voice operation on the application program to trigger, or can be generated by triggering a timing event.
The resource information list is a list formed by static resource information corresponding to web pages in an application program, that is, the resource information list describes static resource information related to static resources, the resource list includes, but is not limited to, a static resource identifier corresponding to each web page of the application program, a static resource path in which static resources corresponding to the static resource identifier are deployed in a static server, and a resource hash value corresponding to the static resource identifier, where the static resource identifier is used to uniquely identify the corresponding static resource.
When the static resource information in the resource information list needs to be updated or one or more types of static resources are newly added, the resource information list is updated accordingly, the updated resource information list is different versions, that is, the resource information list needs to be updated iteratively, the resource information list corresponding to one version is updated iteratively each time, and the resource information lists of different versions can be identified by using the list version hash value. That is, the resource information lists all have corresponding list version hash values, the list version hash values are used for uniquely identifying resource information lists of different versions, the resource information lists can be identified by the hash values, and the hash values are calculated by using a hash algorithm and are obtained by performing encryption operation on static resources to obtain character strings consisting of numbers and letters. The Hash algorithm Hash, which is generally translated as a Hash, or transliteration into a Hash, is to transform an input (also called pre-map image) of any length into an output of a fixed length through a Hash algorithm, where the output is a Hash value. This transformation is a kind of compression mapping, i.e. the space of hash values is usually much smaller than the space of inputs, different inputs may hash to the same output, so it is not possible to determine a unique input value from a hash value. In short, it is a function of compressing a message of an arbitrary length to a message digest of a certain fixed length. When the list version hash value corresponding to the resource information list changes, it indicates that the static resource in the resource information list changes.
The static resource path is a storage path in which the static resource corresponding to the static resource identifier is deployed in the static resource server, that is, the corresponding static resource can be acquired from the static resource server through the static resource path. The resource hash value corresponding to the static resource identifier is used to identify the static resource identifier, and here, the hash value may be used to identify the corresponding static resource identifier.
In one embodiment, the data structure of the resource information list may be as follows:
specifically, the resource information list may be deployed in the interface server in advance, after the terminal obtains a start instruction of the application program, the start instruction is sent to the interface server, the interface server returns the current resource information list to the terminal according to the start instruction, the current resource information list has a corresponding hash value of a current list version, and the current resource information list includes a static resource identifier, a static resource path corresponding to the static resource identifier, and a current resource hash value corresponding to the static resource identifier.
And step 206, acquiring the initial resource information list of the local cache, and determining a static resource path to be updated corresponding to the static resource identifier to be updated in the current resource information list according to the current resource information list and the initial resource information list when the hash value of the version of the current list is inconsistent with the hash value of the version of the initial list corresponding to the initial resource information list.
The initial resource information list is a resource information list locally cached by the terminal, and the static resource in the resource information list locally cached by the terminal can be continuously updated, that is, the static resource updated last time can be cached to the local by the resource information list and can be used as the initial resource information list locally cached next time. When the terminal starts the application program for the first time, the terminal does not have the initial resource information list cached locally at this time, the current resource information list in the interface server can be downloaded in full and cached locally directly, and when the terminal acquires the instruction for starting the application program for the next time, the locally cached resource information list can be used as the initial resource information list. Whether the current resource information list is changed or not can be determined according to the initial list version hash value of the initial resource information list cached locally and the current list version hash value corresponding to the current resource information list, when the initial list version hash value is inconsistent with the current list version hash value, the current resource information list is changed, otherwise, when the initial list version hash value is consistent with the current list version hash value, the current resource information list is not changed, and subsequent steps are not required to be executed.
Specifically, when the hash value of the version of the initial list is not consistent with the hash value of the version of the current list, it is determined that the current resource information list is changed, and it is required to determine which specific static resource in the current resource information list is changed, so that the initial resource information list and the current resource information list can be traversed, the initial resource information list and the current resource information list are compared, and the different resource hash values of the same static resource identifier in the two resource information lists are determined as the static resource identifier to be updated.
And 208, sending the static resource path to be updated to the static resource server through a resource loading request, wherein the resource loading request is used for indicating the static resource server to acquire and return the corresponding target static resource according to the static resource path to be updated.
The path of the static resource to be updated is a path corresponding to the static resource to be updated, and the static resource to be updated and the corresponding static resource of the local cache are changed, so that the static resource to be updated needs to be acquired from the static resource server. Specifically, the static resource path to be updated may be sent to the static resource server through a resource loading request, where the resource loading request is used to request the static resource to be updated, and the static resource server may store the static resource in advance, and store the static resource that has been updated in advance in the static resource server each time.
Further, after receiving the resource loading request, the static resource server searches for the matched target static resource according to the static resource path to be updated in the resource loading request, and returns the target static resource to the terminal. That is to say, when a certain static resource in the resource information list cached locally by the terminal changes, only the changed static resource needs to be updated, and the whole resource information list does not need to be updated, so that the pressure of the terminal is reduced, the data volume for updating the static resource is reduced, and the updating efficiency of the static resource is improved.
And step 210, performing hash value calculation on the returned target static resource to obtain a corresponding hash value of the target resource.
Specifically, the terminal receives the target static resource returned by the static resource server, and since the target static resource is changed compared with the corresponding static resource cached locally, the resource hash value corresponding to the target static resource is also changed accordingly, and the resource hash value corresponding to the target static resource needs to be updated, specifically, the hash value of the returned target static resource may be calculated to obtain the corresponding target resource hash value. The hash value calculation may be a hash value obtaining algorithm, the hash value algorithm is a cryptographic algorithm that can only encrypt and cannot decrypt, information of any length can be converted into a string of fixed length, such as a hash function, and the hash value calculation is performed on the target static resource according to the hash algorithm to obtain a corresponding hash value of the target resource. The resource hash value is a group of binary values obtained by performing encryption operation on the target static resource.
Specifically, after a target resource hash value corresponding to the target static resource is obtained, whether the target resource hash value is consistent with a current resource hash value corresponding to the local cache is detected, when the target resource hash value is inconsistent with the current resource hash value, it is indicated that the target static resource download fails, and the target static resource is discarded, otherwise, when the target resource hash value is consistent with the current resource hash value, it is indicated that the current static resource corresponding to the local cache is successfully updated, and the target static resource is cached to the local.
For example, the initial resource information list of the local cache includes A, B and C, the current resource hash value corresponding to a is 110, the current resource hash value corresponding to B is 100, the current resource hash value corresponding to C is 111, and the current resource information list also includes A, B and C, the current resource hash value corresponding to a is 110, the current resource hash value corresponding to B is 100, and the current resource hash value corresponding to C is 110, where it may be determined that the static resource to be updated is C, a request is made from the static resource server to return the latest static resource C, and the hash algorithm is performed on the latest static resource C to obtain the corresponding target resource hash value of 110, and then the target static resource is considered to be successfully downloaded, and the latest static resource C replaces the static resource C of the local cache. On the contrary, if the hash algorithm calculation is performed on the latest static resource C to obtain the corresponding target resource hash value which is not 110, the target static resource is considered to be failed to download, and the static resource C returned by the static resource server is discarded.
In the static resource caching method, after an application program is started, a current resource information list is requested from an interface server, the current resource information list is compared with a local cached initial resource information list to obtain a static resource identifier to be updated, which is only changed, in the current resource information list, a corresponding target static resource is obtained from the static resource server according to a static resource path to be updated, which corresponds to the static resource identifier to be updated in the current resource information list, hash value calculation is performed on the target static resource to obtain a hash value of the target resource, and when the hash value of the target resource is consistent with the hash value of the corresponding current resource, the target static resource is cached. Therefore, when the application program needs to pass through the static resource of the latest version or update the locally cached static resource, all the static resources corresponding to the application program do not need to be downloaded again, and only the changed static resource needs to be updated, so that the flow of the user is reduced, and the bandwidth and the pressure of the service are also saved.
In one embodiment, as shown in fig. 3, the static resource caching method further includes:
The method comprises the steps that a webpage operation file is a file related to application program webpage operation, the webpage operation file can be an html file, after a terminal obtains a starting instruction of an application program, the starting instruction is sent to a rendering server and an interface server at the same time, the webpage operation file is requested from the rendering server, and a static resource information list is requested from the interface server. After receiving a starting instruction sent by a terminal, a rendering server acquires a webpage code file, wherein the webpage code file is a related file realized by an application program webpage and can be a json file, and the acquired webpage code file is subjected to virtual tree construction, so that a webpage operation file is obtained. The virtual tree is constructed by using json file to generate a tree-shaped data structure. The generation process of the webpage running file is deployed to the rendering server for implementation, the terminal can directly obtain the implemented webpage running file, the webpage running file is not required to be implemented locally at the terminal, the time for the terminal to construct the virtual tree is reduced, and therefore webpage rendering efficiency is saved (note: the webpage rendering efficiency is improved).
And 304, acquiring the webpage running static resource required by the webpage running file from the cached static resource, executing the webpage running file according to the webpage running static resource, and rendering to obtain the target webpage.
Specifically, after the terminal receives the webpage running file returned by the rendering server, because the rendering of the webpage still needs to be performed through static resources such as pictures, JS files, CSS files, and the like, the webpage running static resource required by the webpage running file is obtained from the static resources cached locally at the terminal, and finally, the webpage running file is executed according to the webpage running static resource, and the target webpage is obtained through rendering.
That is to say, when the terminal renders the target webpage, the terminal does not need to build a virtual tree locally, directly obtains the webpage running file from the rendering server, matches the webpage running static resource required by the webpage running file from the static resource cached locally, and finally directly executes the webpage running file according to the webpage running static resource to render the target webpage, so that the virtual tree building time is reduced, the target webpage is rendered before the target webpage is clicked, and the webpage rendering efficiency is improved. Therefore, after the terminal acquires the entry instruction of the target webpage, the target webpage is rendered before, so that the terminal can directly display the target webpage after detecting the entry instruction of the target webpage, the white screen time of the webpage in the application program is reduced, and the display speed of the target webpage is improved.
In one embodiment, as shown in fig. 4, the static resource caching method further includes:
And step 406, searching a static resource path corresponding to the local cache according to the resource hash value of the static resource specified by the request.
After the terminal acquires a starting instruction of an application program, an access request corresponding to a webpage can be generated through triggering of a display interface of the application program, when the terminal detects the access request of the webpage, all requests for loading the webpage of the application program are intercepted, namely, each request in the webpage is intercepted, the intercepted requests are analyzed, and a resource hash value of a static resource of the request instruction is determined. That is to say, the intercepted request is analyzed, the static resource corresponding to the match is searched from the static resource cached locally according to the request, and the resource hash value corresponding to the matched static resource is obtained.
Further, the static resource path of the local cache may be spliced according to the resource hash value of the static resource specified by the request, specifically, the static resource of the local cache may be searched according to the sequence of the resource hash values, and the static resource path corresponding to the static resource obtained by searching is obtained.
At step 410, a first static resource is received and cached.
After obtaining the static resource path corresponding to the searched static resource, it is required to detect whether the searched static resource path is valid, and if the searched static resource path is valid, it indicates that the static resource is included in the local cache of the terminal, otherwise, if the searched static resource path is invalid, it indicates that the static resource is not included in the local cache of the terminal. Therefore, the static resource corresponding to the request needs to be acquired from the static resource server. Specifically, if the found static resource path is invalid, a static resource acquisition request is sent to the static resource server, so that the static resource server returns the corresponding first static resource according to the static resource acquisition request. The static resource acquisition request is used for requesting to acquire the corresponding static resource and can be generated by performing operation triggering through a relevant interface of an application program of the terminal.
Further, the static resource server receives a static resource obtaining request sent by the terminal, the static resource obtaining request carries a static resource identifier, the static resource server searches for a matched static resource according to the static resource obtaining request, the searched static resource is used as a first static resource, the first static resource is returned to the terminal, and the first static resource is matched with the intercepted request.
And finally, the terminal receives the first static resource returned by the static resource server and caches the first static resource to the local.
In one embodiment, as shown in fig. 5, the static resource caching method further includes:
The source code of the project is also called source code and source program, i.e. program code written by a programmer (programmer), and the source code of the project is generally es6 (embedded 2016 standard language), sass (css pre-compilation language), uncompressed picture resources, etc., and different application programs correspond to different source codes of the project. Specifically, a project source code corresponding to the application program is obtained, and the project source code is constructed by using a resource packaging program to obtain a resource information list, a webpage running file and static resources. The resource packaging program is used for compressing and packaging the project source code, and may be webpack, etc., and existing resource packaging programs may be used, without any limitation. Before the application program is online, the project source code corresponding to the application program can be acquired, the resource packaging program is installed, the project source code is compressed and constructed by the resource packaging program (such as webpack), the project source code is automatically processed, and a resource information list, a webpage running file and static resources can be respectively obtained.
In one embodiment, the resource packaging program is webpack, and the step of compressing the project source code by the webpack to obtain the static resource may be: after the webpack plug-in is configured in a common way, the static resources such as js files, css files and picture files can be generated correspondingly through packaging and construction. In one embodiment, the resource packaging program is webpack, and the step of compressing the project source code by the webpack to construct the resource information list may be: webpack provides a way for users to customize plug-in development. When the webpack plug-in is developed, the life cycle of a certain event is monitored, and in the life cycle, the list of the static resources which are built by the webpack and stored in the local and the local storage path corresponding to the list of the static resources can be obtained through the compiler object. At this step, the resource information list may be obtained, and the static resource is read and then subjected to hash calculation using a hash algorithm (e.g., md5 algorithm), so as to obtain a corresponding resource hash value. In addition, through the static resource deployment rule, the static resource path corresponding to each static resource in the static resource server after the static resource in the static resource information list is deployed to the static resource server can be calculated.
In one embodiment, the resource packaging program is webpack, and the step of compressing the project source code by the webpack to construct the web page running file may be: the webpack acquires a webpage code file required by the webpage running file according to the project source code, and constructs a virtual tree for the webpage code file so as to obtain the webpage running file.
Furthermore, after the resource information list, the webpage running file and the static resource are obtained, the resource information list, the webpage running file and the static resource are respectively deployed to corresponding servers and processed through different servers, and therefore processing efficiency is improved. Specifically, the resource information list is deployed to the interface server, the web page running file is deployed to the rendering server, and the static resource is deployed to the static resource server, where the resource information list includes a static resource path corresponding to the static resource deployment to the static resource server.
In an embodiment, as shown in fig. 6, when the hash value of the current list version is inconsistent with the hash value of the initial list version corresponding to the initial resource information list, determining a static resource path to be updated corresponding to a static resource identifier to be updated in the current resource information list according to the current resource information list and the initial resource information list includes:
The determining step may specifically include obtaining an initial list version hash value corresponding to the locally cached initial resource information list, obtaining a current list version hash value corresponding to the current resource information list, detecting whether the initial list version hash value is consistent with the current list version hash value, and when the initial list version hash value is consistent with the current list version hash value, indicating that the current resource information list is the same as the locally cached resource information list, and discarding the current resource information list without performing subsequent steps.
When the detected hash value of the version of the initial list is inconsistent with the hash value of the version of the current list, it is indicated that the current resource information list is changed compared with the locally cached initial resource information list, and a specific changed static resource identifier needs to be determined. Specifically, a first resource hash value is obtained, where the first resource hash value is a resource hash value of the first static resource identifier corresponding to the current resource information list.
The first static resource is a static resource in the current resource information list, and a static resource identifier may be randomly determined from the current resource information list as the first static resource identifier, or sequentially determined as the first static resource according to the sequence of the static resource identifiers.
The method comprises the steps that the same static resources exist in a current resource information list and a locally cached initial resource information list, and after a first static resource identifier is determined from the static resources of the current resource information list, a resource hash value corresponding to the first static resource identifier in the initial resource information list is used as a second resource hash value. That is, the second resource hash value here is the resource hash value corresponding to the first static resource identifier in the initial resource information list.
When the first resource hash value is consistent with the second resource hash value, it is indicated that the first static resource identifier in the current resource information list is not changed compared with the first static resource identifier in the initial resource information list cached locally, and the static resource corresponding to the first static resource identifier does not need to be updated.
On the contrary, when the first resource hash value is inconsistent with the second resource hash value, it indicates that the first static resource identifier in the current resource information list is changed compared with the first static resource identifier in the initial resource information list of the local cache, and therefore the first static resource identifier of the local cache needs to be updated, and therefore the first static resource identifier is determined as the static resource identifier to be updated, and the first static resource path corresponding to the first static resource identifier is determined as the static resource path to be updated.
For example, the list of locally cached initial resource information is as follows:
static resource identification | Resource hash value | Static resource path |
A | 111 | xxxxxxx1 |
B | 100 | xxxxxxx2 |
C | 101 | xxxxxxx3 |
The current resource information list is as follows:
static resource identification | Resource hash value | Static resource path |
A | 111 | xxxxxxx4 |
B | 110 | xxxxxxx5 |
C | 101 | xxxxxxx6 |
Wherein, the hash value of the list version corresponding to the initial resource information list and the hash value of the list version corresponding to the current resource information list can be known, the current resource information list is changed from the initial resource information list, so that a first static resource identifier is obtained from the current resource information list, the static resource identifier B may be randomly obtained, for example, as the first static resource, the hash value of the first resource corresponding to the first static resource in the current resource information list is obtained as 110, the hash value of the second resource corresponding to the first static resource in the initial resource information list is obtained as 100, and determining the static resource path corresponding to the static resource identifier B as the static resource path to be updated corresponding to the static resource identifier to be updated.
In an embodiment, as shown in fig. 7, performing hash value calculation on the returned target static resource to obtain a corresponding hash value of the target resource includes:
Here, the hash value algorithm is used to calculate the hash value, and MD5(MessageDigestAlgorithm 5, information digest algorithm 5) may be used as the hash algorithm. Specifically, after receiving the target static resource returned by the static resource server, the terminal acquires a hash algorithm, and performs hash value calculation on the target static resource through the hash algorithm, so as to obtain a corresponding hash value of the target resource. The hash value calculation may be a hash value obtaining algorithm, the hash value algorithm is a cryptographic algorithm that can only encrypt and cannot decrypt, information of any length can be converted into a string of fixed length, such as a hash function, and the hash value calculation is performed on the target static resource according to the hash algorithm to obtain a corresponding hash value of the target resource. The resource hash value is a group of binary values obtained by performing encryption operation on the target static resource.
In a specific embodiment, a static resource caching method is provided, which specifically includes the following steps:
1. and acquiring the project source code corresponding to the application program.
2. And constructing the project source code by using a resource packaging program to obtain a resource information list, a webpage running file and static resources.
3. The resource information list is deployed into an interface server, the webpage running file is deployed into a rendering server, the static resource is deployed into a static resource server, and the resource information list comprises a static resource path corresponding to the static resource deployment to the static resource server.
4. And acquiring a starting instruction of the application program, wherein the starting instruction is used for indicating the starting of the application program.
5. And requesting a current resource information list from the interface server according to the starting instruction, wherein the current resource information list has a corresponding current list version hash value, and the current resource information list comprises a static resource identifier, a static resource path corresponding to the static resource identifier and a current resource hash value corresponding to the static resource identifier.
6. And when the hash value of the version of the current list is inconsistent with the hash value of the version of the initial list corresponding to the initial resource information list, determining a path of the static resource to be updated corresponding to the static resource identifier to be updated in the current resource information list according to the current resource information list and the initial resource information list.
And 6-1, acquiring the hash value of the version of the initial list corresponding to the initial resource information list.
And 6-2, when the hash value of the initial list version is inconsistent with the hash value of the current list version, acquiring a first resource hash value, wherein the first resource hash value is a resource hash value corresponding to the first static resource identifier in the current resource information list.
And 6-3, acquiring a second resource hash value, wherein the second resource hash value is the resource hash value corresponding to the first static resource identifier in the initial resource information list.
And 6-4, when the first resource hash value is not consistent with the second resource hash value, determining that the first static resource identifier is a static resource identifier to be updated, and determining a first static resource path corresponding to the first static resource identifier as the static resource path to be updated.
7. And sending the static resource path to be updated to the static resource server through a resource loading request, wherein the resource loading request is used for indicating the static resource server to acquire and return the corresponding target static resource according to the static resource path to be updated.
8. And performing hash value calculation on the returned target static resource to obtain a corresponding hash value of the target resource.
8-1, obtaining a hash value algorithm.
And 8-2, performing hash value calculation on the target static resource according to a hash value algorithm to obtain a corresponding hash value of the target resource.
9. And when the hash value of the target resource is consistent with the corresponding hash value of the current resource, caching the target static resource.
10. And requesting a webpage running file from the rendering server according to the starting instruction, wherein the webpage running file is obtained by the rendering server through virtual tree construction according to the webpage code file.
11. And acquiring the webpage running static resource required by the webpage running file from the cached static resource, executing the webpage running file according to the webpage running static resource, and rendering to obtain the target webpage.
12. A request to load an application webpage is intercepted.
13. And analyzing the request and determining the resource hash value of the static resource specified by the request.
14. And searching a static resource path corresponding to the local cache according to the resource hash value of the static resource specified by the request.
15. And if the searched static resource path is invalid, sending a static resource acquisition request to the static resource server so that the static resource server returns the corresponding first static resource according to the static resource acquisition request.
16. A first static resource is received and cached.
It should be understood that, although the steps in the above-described flowcharts are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps in the above-described flowcharts may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of performing the sub-steps or the stages is not necessarily sequential, but may be performed alternately or alternatingly with other steps or at least a portion of the sub-steps or stages of other steps.
In one embodiment, as shown in FIG. 8, a static resource caching system 800 is provided, wherein:
the terminal 802 is configured to obtain a start instruction of an application, where the start instruction is used to instruct to start the application and send the start instruction to the interface server.
The interface server 804 is configured to receive a start instruction, request a current resource information list according to the start instruction, where the current resource information list has a corresponding hash value of a current list version, and the current resource information list includes a static resource identifier, a static resource path corresponding to the static resource identifier, and a current resource hash value corresponding to the static resource identifier.
The terminal 802 is configured to receive the current resource information list, obtain an initial resource information list cached locally, determine, according to the current resource information list and the initial resource information list, a to-be-updated static resource path corresponding to a to-be-updated static resource identifier in the current resource information list when the current list version hash value is inconsistent with the initial list version hash value corresponding to the initial resource information list, and send the to-be-updated static resource path to the static resource server through a resource loading request.
And the static resource server 806 is configured to receive the resource loading request, load the static resource according to the path of the static resource to be updated in the resource loading request, and return the corresponding target static resource to the terminal.
And the terminal 802 is configured to receive the returned target static resource, perform hash value calculation on the target static resource to obtain a corresponding hash value of the target resource, and cache the target static resource when the hash value of the target resource is consistent with the corresponding hash value of the current resource.
In one embodiment, as shown in fig. 9, the static resource caching system 800 further includes a rendering server 808, wherein the terminal 802 is further configured to: and sending a starting instruction to the rendering server.
And the rendering server 808 is configured to receive the starting instruction, acquire the webpage code file according to the starting instruction, construct a virtual tree according to the webpage code file to obtain a webpage running file, and return the webpage running file to the terminal.
The terminal 802 is further configured to obtain a webpage running static resource required by the webpage running file from the cached static resource, execute the webpage running file according to the webpage running static resource, and render to obtain a target webpage.
In an embodiment, the terminal 802 is further configured to intercept a request for loading an application webpage, analyze the request, determine a resource hash value of a static resource specified by the request, search a static resource path corresponding to a local cache according to the resource hash value of the static resource specified by the request, and send a static resource acquisition request to the static resource server if the found static resource path is invalid, so that the static resource server returns a corresponding first static resource according to the static resource acquisition request, and receives and caches the first static resource.
In an embodiment, the terminal 802 is further configured to obtain a project source code corresponding to the application program, construct the project source code by using a resource packaging program, obtain a resource information list, a web page running file, and a static resource, deploy the resource information list to the interface server 804, deploy the web page running file to the rendering server 808, and deploy the static resource to the static resource server 806, where the resource information list includes a static resource path corresponding to the static resource server to which the static resource is deployed.
In an embodiment, the terminal 802 is further configured to obtain an initial list version hash value corresponding to the initial resource information list, obtain a first resource hash value when the initial list version hash value is inconsistent with the current list version hash value, obtain a second resource hash value when the initial list version hash value is inconsistent with the current list version hash value, and determine that the first static resource identifier is the static resource identifier to be updated and the first static resource path corresponding to the first static resource identifier is determined as the static resource path to be updated when the first resource hash value is inconsistent with the second resource hash value.
In an embodiment, the terminal 802 is further configured to obtain a hash value algorithm, and perform hash value calculation on the target static resource according to the hash value algorithm to obtain a corresponding hash value of the target resource.
In one embodiment, as shown in fig. 10, there is provided a static resource caching apparatus 1000, including: a starting instruction obtaining module 1002, a current resource information list requesting module 1004, an initial resource information list obtaining module 1006, a resource loading request sending module 1008, a resource hash value calculating module 1010 and a target static resource caching module 1012, wherein:
the starting instruction obtaining module 1002 is configured to obtain a starting instruction of an application program, where the starting instruction is used to instruct to start the application program.
A current resource information list requesting module 1004, configured to request, according to the start instruction, a current resource information list from the interface server, where the current resource information list has a corresponding current list version hash value, and the current resource information list includes a static resource identifier, a static resource path corresponding to the static resource identifier, and a current resource hash value corresponding to the static resource identifier.
An initial resource information list obtaining module 1006, configured to obtain a locally cached initial resource information list, and when the hash value of the current list version is inconsistent with the hash value of the initial list version corresponding to the initial resource information list, determine, according to the current resource information list and the initial resource information list, a to-be-updated static resource path corresponding to the to-be-updated static resource identifier in the current resource information list.
A resource loading request sending module 1008, configured to send the static resource path to be updated to the static resource server through a resource loading request, where the resource loading request is used to instruct the static resource server to obtain and return the corresponding target static resource according to the static resource path to be updated.
And the resource hash value calculation module 1010 is configured to perform hash value calculation on the returned target static resource to obtain a corresponding target resource hash value.
And a target static resource caching module 1012, configured to cache the target static resource when the hash value of the target resource is consistent with the corresponding hash value of the current resource.
In an embodiment, the static resource caching apparatus 1000 is further configured to request a web page operating file from the rendering server according to the start instruction, where the web page operating file is obtained by the rendering server by performing virtual tree construction according to a web page code file, obtain a web page operating static resource required by the web page operating file from the cached static resource, execute the web page operating file according to the web page operating static resource, and perform rendering to obtain the target web page.
In an embodiment, the static resource caching apparatus 1000 is further configured to intercept a request for loading an application webpage, analyze the request, determine a resource hash value of a static resource specified by the request, search a static resource path corresponding to the local cache according to the resource hash value of the static resource specified by the request, and send a static resource acquisition request to the static resource server if the found static resource path is invalid, so that the static resource server returns a corresponding first static resource according to the static resource acquisition request, and receives and caches the first static resource.
In an embodiment, the static resource caching apparatus 1000 is further configured to obtain a project source code corresponding to the application program, construct the project source code by using a resource packaging program, obtain a resource information list, a web page running file, and a static resource, deploy the resource information list to the interface server, deploy the web page running file to the rendering server, and deploy the static resource to the static resource server, where the resource information list includes a static resource path corresponding to the static resource server where the static resource is deployed.
In an embodiment, the static resource caching apparatus 1000 is further configured to obtain an initial list version hash value corresponding to the initial resource information list, obtain a first resource hash value when the initial list version hash value is inconsistent with the current list version hash value, where the first resource hash value is a resource hash value of the first static resource identifier corresponding to the current resource information list, obtain a second resource hash value, where the second resource hash value is a resource hash value of the first static resource identifier corresponding to the initial resource information list, when the first resource hash value is inconsistent with the second resource hash value, determine that the first static resource identifier is a static resource identifier to be updated, and determine the first static resource path corresponding to the first static resource identifier as the static resource path to be updated.
In an embodiment, the static resource caching apparatus 1000 is further configured to obtain a hash value algorithm, and perform hash value calculation on the target static resource according to the hash value algorithm to obtain a corresponding hash value of the target resource.
For specific limitations of the static resource caching apparatus, reference may be made to the above limitations of the static resource caching method, which is not described herein again. The modules in the static resource caching device can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
FIG. 11 is a diagram illustrating an internal structure of a computer device in one embodiment. The computer device may specifically be the terminal 102 in fig. 1. As shown in fig. 11, the computer apparatus includes a processor, a memory, a network interface, an input device, and a display screen connected through a system bus. Wherein the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program that, when executed by the processor, causes the processor to implement the static resource caching method. The internal memory may also have stored therein a computer program that, when executed by the processor, causes the processor to perform a static resource caching method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 11 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program: obtaining a start instruction of an application program, wherein the start instruction is used for indicating the start of the application program, requesting a current resource information list from an interface server according to the start instruction, the current resource information list has a corresponding current list version hash value, the current resource information list comprises a static resource identifier, a static resource path corresponding to the static resource identifier and a current resource hash value corresponding to the static resource identifier, obtaining an initial resource information list of a local cache, when the current list version hash value is inconsistent with the initial list version hash value corresponding to the initial resource information list, determining a to-be-updated static resource path corresponding to the to-be-updated static resource identifier in the current resource information list according to the current resource information list and the initial resource information list, and sending the to-be-updated static resource path to the static resource server through a resource loading request, and the resource loading request is used for indicating the static resource server to acquire and return the corresponding target static resource according to the static resource path to be updated, performing hash value calculation on the returned target static resource to obtain a corresponding target resource hash value, and caching the target static resource when the target resource hash value is consistent with the corresponding current resource hash value.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and requesting a webpage running file from the rendering server according to the starting instruction, wherein the webpage running file is obtained by the rendering server through virtual tree construction according to the webpage code file, acquiring the webpage running static resource required by the webpage running file from the cached static resource, executing the webpage running file according to the webpage running static resource, and rendering to obtain the target webpage.
In one embodiment, the processor, when executing the computer program, further performs the steps of: intercepting a request for loading an application program webpage, analyzing the request, determining a resource hash value of a static resource specified by the request, splicing a locally cached static resource path according to the resource hash value of the static resource specified by the request, and if the static resource path is invalid, sending a static resource acquisition request to a static resource server so that the static resource server returns a corresponding first static resource according to the static resource acquisition request, and receiving and caching the first static resource.
In one embodiment, the processor, when executing the computer program, further performs the steps of: the method comprises the steps of obtaining a project source code corresponding to an application program, constructing the project source code by using a resource packaging program to obtain a resource information list, a webpage running file and static resources, deploying the resource information list into an interface server, deploying the webpage running file into a rendering server, deploying the static resources into a static resource server, wherein the resource information list comprises a static resource path corresponding to the static resource server from the static resources.
In one embodiment, the processor, when executing the computer program, further performs the steps of: the method comprises the steps of obtaining an initial list version hash value corresponding to an initial resource information list, obtaining a first resource hash value when the initial list version hash value is inconsistent with a current list version hash value, obtaining a second resource hash value when the first resource hash value is a resource hash value of a first static resource identifier corresponding to the current resource information list, obtaining a second resource hash value when the second resource hash value is a resource hash value of the first static resource identifier corresponding to the initial resource information list, determining the first static resource identifier as a static resource identifier to be updated when the first resource hash value is inconsistent with the second resource hash value, and determining a first static resource path corresponding to the first static resource identifier as a static resource path to be updated.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and acquiring a hash value algorithm, and calculating the hash value of the target static resource according to the hash value algorithm to obtain the corresponding hash value of the target resource.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of: obtaining a start instruction of an application program, wherein the start instruction is used for indicating the start of the application program, requesting a current resource information list from an interface server according to the start instruction, the current resource information list has a corresponding current list version hash value, the current resource information list comprises a static resource identifier, a static resource path corresponding to the static resource identifier and a current resource hash value corresponding to the static resource identifier, obtaining an initial resource information list of a local cache, when the current list version hash value is inconsistent with the initial list version hash value corresponding to the initial resource information list, determining a to-be-updated static resource path corresponding to the to-be-updated static resource identifier in the current resource information list according to the current resource information list and the initial resource information list, and sending the to-be-updated static resource path to the static resource server through a resource loading request, and the resource loading request is used for indicating the static resource server to acquire and return the corresponding target static resource according to the static resource path to be updated, performing hash value calculation on the returned target static resource to obtain a corresponding target resource hash value, and caching the target static resource when the target resource hash value is consistent with the corresponding current resource hash value.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and requesting a webpage running file from the rendering server according to the starting instruction, wherein the webpage running file is obtained by the rendering server through virtual tree construction according to the webpage code file, acquiring the webpage running static resource required by the webpage running file from the cached static resource, executing the webpage running file according to the webpage running static resource, and rendering to obtain the target webpage.
In one embodiment, the processor, when executing the computer program, further performs the steps of: intercepting a request for loading an application program webpage, analyzing the request, determining a resource hash value of a static resource specified by the request, splicing a locally cached static resource path according to the resource hash value of the static resource specified by the request, and if the static resource path is invalid, sending a static resource acquisition request to a static resource server so that the static resource server returns a corresponding first static resource according to the static resource acquisition request, and receiving and caching the first static resource.
In one embodiment, the processor, when executing the computer program, further performs the steps of: the method comprises the steps of obtaining a project source code corresponding to an application program, constructing the project source code by using a resource packaging program to obtain a resource information list, a webpage running file and static resources, deploying the resource information list into an interface server, deploying the webpage running file into a rendering server, deploying the static resources into a static resource server, wherein the resource information list comprises a static resource path corresponding to the static resource server from the static resources.
In one embodiment, the processor, when executing the computer program, further performs the steps of: the method comprises the steps of obtaining an initial list version hash value corresponding to an initial resource information list, obtaining a first resource hash value when the initial list version hash value is inconsistent with a current list version hash value, obtaining a second resource hash value when the first resource hash value is a resource hash value of a first static resource identifier corresponding to the current resource information list, obtaining a second resource hash value when the second resource hash value is a resource hash value of the first static resource identifier corresponding to the initial resource information list, determining the first static resource identifier as a static resource identifier to be updated when the first resource hash value is inconsistent with the second resource hash value, and determining a first static resource path corresponding to the first static resource identifier as a static resource path to be updated.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and acquiring a hash value algorithm, and calculating the hash value of the target static resource according to the hash value algorithm to obtain the corresponding hash value of the target resource.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (10)
1. A method of static resource caching, the method comprising:
acquiring a starting instruction of an application program, wherein the starting instruction is used for indicating to start the application program;
requesting a current resource information list from an interface server according to the starting instruction, wherein the current resource information list has a corresponding current list version hash value, and the current resource information list comprises a static resource identifier, a static resource path corresponding to the static resource identifier and a current resource hash value corresponding to the static resource identifier;
acquiring an initial resource information list of a local cache, and determining a static resource path to be updated corresponding to a static resource identifier to be updated in the current resource information list according to the current resource information list and the initial resource information list when the hash value of the version of the current list is inconsistent with the hash value of the version of the initial list corresponding to the initial resource information list;
sending the static resource path to be updated to a static resource server through a resource loading request, wherein the resource loading request is used for indicating the static resource server to obtain and return a corresponding target static resource according to the static resource path to be updated;
performing hash value calculation on the returned target static resource to obtain a corresponding hash value of the target resource;
and when the target resource hash value is consistent with the corresponding current resource hash value, caching the target static resource.
2. The method of claim 1, further comprising:
requesting a webpage running file from a rendering server according to the starting instruction, wherein the webpage running file is obtained by the rendering server through virtual tree construction according to a webpage code file;
and acquiring the webpage running static resource required by the webpage running file from the cached static resource, executing the webpage running file according to the webpage running static resource, and rendering to obtain the target webpage.
3. The method of claim 1, further comprising:
intercepting a request for loading the application program webpage;
analyzing the request and determining a resource hash value of the static resource specified by the request;
searching a static resource path corresponding to a local cache according to the resource hash value of the static resource specified by the request;
if the found static resource path is invalid, sending a static resource acquisition request to the static resource server so that the static resource server returns a corresponding first static resource according to the static resource acquisition request;
and receiving and caching the first static resource.
4. The method of claim 1, further comprising:
acquiring a project source code corresponding to the application program;
constructing the project source code by using a resource packaging program to obtain a resource information list, a webpage running file and static resources;
deploying the resource information list into the interface server, deploying the webpage running file into a rendering server, and deploying the static resource into the static resource server, wherein the resource information list comprises a static resource path corresponding to the static resource deployment to the static resource server.
5. The method according to claim 1, wherein when the current list version hash value is not consistent with the initial list version hash value corresponding to the initial resource information list, determining a static resource path to be updated corresponding to a static resource identifier to be updated in the current resource information list according to the current resource information list and the initial resource information list includes:
acquiring an initial list version hash value corresponding to the initial resource information list;
when the initial list version hash value is inconsistent with the current list version hash value, acquiring a first resource hash value, wherein the first resource hash value is a resource hash value corresponding to a first static resource identifier in the current resource information list;
acquiring a second resource hash value, wherein the second resource hash value is a resource hash value corresponding to the first static resource identifier in the initial resource information list;
when the first resource hash value is inconsistent with the second resource hash value, determining that the first static resource identifier is a static resource identifier to be updated, and determining a first static resource path corresponding to the first static resource identifier as a static resource path to be updated.
6. The method of claim 1, wherein the performing a hash value calculation on the returned target static resource to obtain a corresponding hash value of the target resource comprises:
obtaining a hash value algorithm;
and carrying out hash value calculation on the target static resource according to the hash value algorithm to obtain a corresponding hash value of the target resource.
7. A static resource caching system, the system comprising:
the terminal is used for acquiring a starting instruction of an application program, wherein the starting instruction is used for indicating the starting of the application program and sending the starting instruction to the interface server;
the interface server is configured to receive the start instruction, request a current resource information list according to the start instruction, where the current resource information list has a corresponding current list version hash value, and the current resource information list includes a static resource identifier, a static resource path corresponding to the static resource identifier, and a current resource hash value corresponding to the static resource identifier;
the terminal is used for receiving the current resource information list, acquiring a locally cached initial resource information list, determining a to-be-updated static resource path corresponding to a to-be-updated static resource identifier in the current resource information list according to the current resource information list and the initial resource information list when the hash value of the version of the current list is inconsistent with the hash value of the version of the initial list corresponding to the initial resource information list, and sending the to-be-updated static resource path to a static resource server through a resource loading request;
the static resource server is used for receiving the resource loading request, loading according to a static resource path to be updated in the resource loading request and returning a corresponding target static resource to the terminal;
and the terminal is used for receiving the returned target static resource, calculating the hash value of the target static resource to obtain the corresponding hash value of the target resource, and caching the target static resource when the hash value of the target resource is consistent with the corresponding hash value of the current resource.
8. An apparatus for static resource caching, the apparatus comprising:
the starting instruction acquisition module is used for acquiring a starting instruction of the application program, and the starting instruction is used for indicating the starting of the application program;
a current resource information list requesting module, configured to request a current resource information list from an interface server according to the start instruction, where the current resource information list has a corresponding current list version hash value, and the current resource information list includes a static resource identifier, a static resource path corresponding to the static resource identifier, and a current resource hash value corresponding to the static resource identifier;
an initial resource information list obtaining module, configured to obtain a locally cached initial resource information list, and when the hash value of the version of the current list is inconsistent with the hash value of the version of the initial list corresponding to the initial resource information list, determine, according to the current resource information list and the initial resource information list, a static resource path to be updated corresponding to a static resource identifier to be updated in the current resource information list;
a resource loading request sending module, configured to send the static resource path to be updated to a static resource server through a resource loading request, where the resource loading request is used to instruct the static resource server to obtain and return a corresponding target static resource according to the static resource path to be updated;
the resource hash value calculation module is used for calculating the hash value of the returned target static resource to obtain a corresponding target resource hash value;
and the target static resource caching module is used for caching the target static resource when the hash value of the target resource is consistent with the corresponding hash value of the current resource.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 6 are implemented when the computer program is executed by the processor.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910924847.1A CN110866198B (en) | 2019-09-27 | 2019-09-27 | Static resource caching method, system, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910924847.1A CN110866198B (en) | 2019-09-27 | 2019-09-27 | Static resource caching method, system, device, computer equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110866198A true CN110866198A (en) | 2020-03-06 |
CN110866198B CN110866198B (en) | 2022-10-28 |
Family
ID=69652439
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910924847.1A Active CN110866198B (en) | 2019-09-27 | 2019-09-27 | Static resource caching method, system, device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110866198B (en) |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111506837A (en) * | 2020-03-09 | 2020-08-07 | 百度在线网络技术(北京)有限公司 | Searching method and device, electronic equipment and readable storage medium |
CN111586170A (en) * | 2020-05-07 | 2020-08-25 | 广州博冠信息科技有限公司 | Resource downloading method, device, equipment and computer readable storage medium |
CN111783005A (en) * | 2020-07-08 | 2020-10-16 | 中国工商银行股份有限公司 | Method, apparatus and system for displaying web page, computer system and medium |
CN112016014A (en) * | 2020-08-18 | 2020-12-01 | 北京达佳互联信息技术有限公司 | Webpage display method, webpage resource generation method, webpage display device, webpage resource generation device, electronic equipment and medium |
CN112073405A (en) * | 2020-09-03 | 2020-12-11 | 中国平安财产保险股份有限公司 | Webpage data loading method and device, computer equipment and storage medium |
CN112182334A (en) * | 2020-09-27 | 2021-01-05 | 东风汽车有限公司 | Vehicle-mounted hypertext markup language file processing method, electronic equipment, server processing method and server |
CN112835578A (en) * | 2021-01-28 | 2021-05-25 | 观脉科技(北京)有限公司 | Bundle file generation method and storage medium |
CN113064609A (en) * | 2021-03-05 | 2021-07-02 | 深圳市欢太科技有限公司 | Resource loading method, client, server and storage medium |
CN113568620A (en) * | 2021-06-16 | 2021-10-29 | 杭州华橙软件技术有限公司 | Code file processing method, device, equipment and medium |
CN113568752A (en) * | 2021-07-29 | 2021-10-29 | 上海浦东发展银行股份有限公司 | Static resource loading method, device, equipment and storage medium |
CN114221953A (en) * | 2021-11-29 | 2022-03-22 | 平安证券股份有限公司 | Resource acquisition method, device, equipment and storage medium |
Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040205650A1 (en) * | 2001-09-10 | 2004-10-14 | Lebin Cheng | Dynamic web content unfolding in wireless information gateways |
US20120185835A1 (en) * | 2011-01-13 | 2012-07-19 | Levy Klots | Static Resource Processing |
CN103269353A (en) * | 2013-04-19 | 2013-08-28 | 网宿科技股份有限公司 | Web cache and return optimization method and Web cache system |
CN104106052A (en) * | 2012-02-16 | 2014-10-15 | 西里克斯系统公司 | Connection leasing for hosted services |
CN104714965A (en) * | 2013-12-16 | 2015-06-17 | 阿里巴巴集团控股有限公司 | Static resource weight removing method, and static resource management method and device |
CN106549995A (en) * | 2015-09-21 | 2017-03-29 | 北京广密华安科技有限公司 | Information cache and the method, apparatus and system for pushing in peer-to-peer network |
CN106878370A (en) * | 2016-09-19 | 2017-06-20 | 阿里巴巴集团控股有限公司 | The update method and equipment of a kind of local cache |
CN107315791A (en) * | 2017-06-14 | 2017-11-03 | 广州酷狗计算机科技有限公司 | Static resource caching method, device and computer-readable recording medium |
CN107992557A (en) * | 2017-11-28 | 2018-05-04 | 平安养老保险股份有限公司 | Static resource update method, device, storage medium and computer equipment |
CN108304207A (en) * | 2018-03-01 | 2018-07-20 | 上海找钢网信息科技股份有限公司 | Mix the resource regeneration method and system of APP application programs |
CN109246229A (en) * | 2018-09-28 | 2019-01-18 | 网宿科技股份有限公司 | A kind of method and apparatus of distribution resource acquisition request |
CN109995834A (en) * | 2017-12-30 | 2019-07-09 | 中国移动通信集团贵州有限公司 | Massive dataflow processing method, calculates equipment and storage medium at device |
CN110263275A (en) * | 2019-06-14 | 2019-09-20 | 深圳前海桔子信息技术有限公司 | A kind of method, apparatus, mobile terminal and storage medium accessing webpage |
-
2019
- 2019-09-27 CN CN201910924847.1A patent/CN110866198B/en active Active
Patent Citations (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20040205650A1 (en) * | 2001-09-10 | 2004-10-14 | Lebin Cheng | Dynamic web content unfolding in wireless information gateways |
US20120185835A1 (en) * | 2011-01-13 | 2012-07-19 | Levy Klots | Static Resource Processing |
CN104106052A (en) * | 2012-02-16 | 2014-10-15 | 西里克斯系统公司 | Connection leasing for hosted services |
CN103269353A (en) * | 2013-04-19 | 2013-08-28 | 网宿科技股份有限公司 | Web cache and return optimization method and Web cache system |
CN104714965A (en) * | 2013-12-16 | 2015-06-17 | 阿里巴巴集团控股有限公司 | Static resource weight removing method, and static resource management method and device |
CN106549995A (en) * | 2015-09-21 | 2017-03-29 | 北京广密华安科技有限公司 | Information cache and the method, apparatus and system for pushing in peer-to-peer network |
CN106878370A (en) * | 2016-09-19 | 2017-06-20 | 阿里巴巴集团控股有限公司 | The update method and equipment of a kind of local cache |
CN107315791A (en) * | 2017-06-14 | 2017-11-03 | 广州酷狗计算机科技有限公司 | Static resource caching method, device and computer-readable recording medium |
CN107992557A (en) * | 2017-11-28 | 2018-05-04 | 平安养老保险股份有限公司 | Static resource update method, device, storage medium and computer equipment |
CN109995834A (en) * | 2017-12-30 | 2019-07-09 | 中国移动通信集团贵州有限公司 | Massive dataflow processing method, calculates equipment and storage medium at device |
CN108304207A (en) * | 2018-03-01 | 2018-07-20 | 上海找钢网信息科技股份有限公司 | Mix the resource regeneration method and system of APP application programs |
CN109246229A (en) * | 2018-09-28 | 2019-01-18 | 网宿科技股份有限公司 | A kind of method and apparatus of distribution resource acquisition request |
CN110263275A (en) * | 2019-06-14 | 2019-09-20 | 深圳前海桔子信息技术有限公司 | A kind of method, apparatus, mobile terminal and storage medium accessing webpage |
Non-Patent Citations (1)
Title |
---|
金秀凤: "大数据时代档案信息资源共享平台数据处理的优化", 《档案管理》 * |
Cited By (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111506837A (en) * | 2020-03-09 | 2020-08-07 | 百度在线网络技术(北京)有限公司 | Searching method and device, electronic equipment and readable storage medium |
CN111586170A (en) * | 2020-05-07 | 2020-08-25 | 广州博冠信息科技有限公司 | Resource downloading method, device, equipment and computer readable storage medium |
CN111783005A (en) * | 2020-07-08 | 2020-10-16 | 中国工商银行股份有限公司 | Method, apparatus and system for displaying web page, computer system and medium |
CN111783005B (en) * | 2020-07-08 | 2024-03-15 | 中国工商银行股份有限公司 | Method, device and system for displaying web page, computer system and medium |
CN112016014B (en) * | 2020-08-18 | 2023-12-26 | 北京达佳互联信息技术有限公司 | Webpage display method, webpage resource generation device, electronic equipment and medium |
CN112016014A (en) * | 2020-08-18 | 2020-12-01 | 北京达佳互联信息技术有限公司 | Webpage display method, webpage resource generation method, webpage display device, webpage resource generation device, electronic equipment and medium |
CN112073405A (en) * | 2020-09-03 | 2020-12-11 | 中国平安财产保险股份有限公司 | Webpage data loading method and device, computer equipment and storage medium |
CN112073405B (en) * | 2020-09-03 | 2024-02-06 | 中国平安财产保险股份有限公司 | Webpage data loading method and device, computer equipment and storage medium |
CN112182334A (en) * | 2020-09-27 | 2021-01-05 | 东风汽车有限公司 | Vehicle-mounted hypertext markup language file processing method, electronic equipment, server processing method and server |
CN112182334B (en) * | 2020-09-27 | 2024-07-05 | 东风汽车有限公司 | Vehicle-mounted hypertext markup language file processing method, electronic equipment, server processing method and server |
CN112835578A (en) * | 2021-01-28 | 2021-05-25 | 观脉科技(北京)有限公司 | Bundle file generation method and storage medium |
CN113064609A (en) * | 2021-03-05 | 2021-07-02 | 深圳市欢太科技有限公司 | Resource loading method, client, server and storage medium |
CN113064609B (en) * | 2021-03-05 | 2024-05-28 | 深圳市欢太科技有限公司 | Resource loading method, client, server and storage medium |
CN113568620A (en) * | 2021-06-16 | 2021-10-29 | 杭州华橙软件技术有限公司 | Code file processing method, device, equipment and medium |
CN113568620B (en) * | 2021-06-16 | 2023-08-22 | 杭州华橙软件技术有限公司 | Code file processing method, device, equipment and medium |
CN113568752A (en) * | 2021-07-29 | 2021-10-29 | 上海浦东发展银行股份有限公司 | Static resource loading method, device, equipment and storage medium |
CN114221953A (en) * | 2021-11-29 | 2022-03-22 | 平安证券股份有限公司 | Resource acquisition method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110866198B (en) | 2022-10-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110866198B (en) | Static resource caching method, system, device, computer equipment and storage medium | |
CN109814854B (en) | Project framework generation method, device, computer equipment and storage medium | |
CN109471988B (en) | Page information updating method and device, computer equipment and storage medium | |
CN110688598B (en) | Service parameter acquisition method and device, computer equipment and storage medium | |
CN108829477B (en) | Interface jump method, device, computer equipment and storage medium | |
CN111245548A (en) | Data synchronization method and device based on timestamp and computer equipment | |
CN110489429B (en) | Data acquisition method and device, computer readable storage medium and computer equipment | |
CN111563365B (en) | Method and device for processing modification information of test standard worksheet and computer equipment | |
CN110365724B (en) | Task processing method and device and electronic equipment | |
CN108256014B (en) | Page display method and device | |
CN109361628B (en) | Message assembling method and device, computer equipment and storage medium | |
CN106534268B (en) | Data sharing method and device | |
CN110362341B (en) | Business management method, device, equipment and storage medium based on micro-service architecture | |
CN110213392B (en) | Data distribution method and device, computer equipment and storage medium | |
CN112000903B (en) | Data query method and device, computer equipment and storage medium | |
CN112637008B (en) | Link simulation test method, device, system, computer equipment and storage medium | |
CN112241298A (en) | Page display method and device, storage medium and electronic device | |
CN112527357A (en) | Service hot loading updating method and device, computer equipment and storage medium | |
CN111083054B (en) | Route configuration processing method and device, computer equipment and storage medium | |
CN111597490A (en) | Web fingerprint identification method, device, equipment and computer storage medium | |
CN111309379A (en) | Project generation method and device, computer equipment and storage medium | |
CN111597422A (en) | Buried point mapping method and device, computer equipment and storage medium | |
CN112783866B (en) | Data reading method, device, computer equipment and storage medium | |
CN111901383A (en) | Data request processing method and device, computer equipment and storage medium | |
CN111191235A (en) | Suspicious file analysis method and device and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |