CN114117280A - Page static resource using method and device, terminal equipment and storage medium - Google Patents

Page static resource using method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN114117280A
CN114117280A CN202111439845.7A CN202111439845A CN114117280A CN 114117280 A CN114117280 A CN 114117280A CN 202111439845 A CN202111439845 A CN 202111439845A CN 114117280 A CN114117280 A CN 114117280A
Authority
CN
China
Prior art keywords
page
static resource
server
static
page static
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.)
Pending
Application number
CN202111439845.7A
Other languages
Chinese (zh)
Inventor
贾鹏辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An E Wallet Electronic Commerce Co Ltd
Original Assignee
Ping An E Wallet Electronic Commerce Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Ping An E Wallet Electronic Commerce Co Ltd filed Critical Ping An E Wallet Electronic Commerce Co Ltd
Priority to CN202111439845.7A priority Critical patent/CN114117280A/en
Publication of CN114117280A publication Critical patent/CN114117280A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore

Abstract

The embodiment of the application is applicable to the technical field of research and development management, and provides a page static resource using method, a device, terminal equipment and a storage medium, wherein the method is applied to the terminal equipment, and the terminal equipment comprises a cache memory; wherein, the method comprises the following steps: acquiring page static resources of each version sent by a server; generating a page route of each page static resource when each page static resource is stored in a cache; after the data connection between the terminal equipment and the server is disconnected, if a data request is received, acquiring a target page static resource of the latest version from a cache memory according to a page route and the data request; and if the static resources of the running target page have errors, rolling back the static resources of the target page of the latest version to the previous version from the cache memory. By adopting the method, the terminal equipment can improve the efficiency of rolling back the static page resources of the previous version.

Description

Page static resource using method and device, terminal equipment and storage medium
Technical Field
The application belongs to the technical field of research and development management, and particularly relates to a method and a device for using static resources of a page, terminal equipment and a storage medium.
Background
In the prior art, when a developer develops a front-end website, static resources of a page are usually changed. And each time the page static resource is changed, the latest version and the last version of the page static resource are stored in the cache of the server. After the front-end device downloads the latest version of the page static resource through the front-end website, if a problem occurs in operation, the front-end device needs to package and download the previous version of the static resource from the server again.
However, re-downloading static resources requires not only that the server first repackage and install the last version of the page static resource, but also that the head-end device be in a networked environment. Further, this process requires the developer to update the server's cache and the server's code again before it can be implemented. Therefore, it is inefficient for the front-end device to roll back the static resource of the previous version of the page.
Disclosure of Invention
The embodiment of the application provides a method and a device for using a page static resource, a terminal device and a storage medium, which can solve the problem of low rollback efficiency when a front-end device rolls back a previous version of the page static resource.
In a first aspect, an embodiment of the present application provides a method for using a static resource of a page, which is applied to a terminal device, where the terminal device includes a cache memory, and the method includes:
acquiring static resources of a page sent by a server; the page static resources comprise at least one, and the version corresponding to each page static resource comprises at least one;
generating a page route of each page static resource when each page static resource is stored in a cache;
after the data connection between the terminal equipment and the server is disconnected, if a data request is received, acquiring a target page static resource of the latest version from a cache memory according to a page route and the data request;
and if the static resources of the running target page have errors, rolling back the static resources of the target page of the latest version to the previous version from the cache memory.
In a second aspect, an embodiment of the present application provides a page static resource using apparatus, which is applied to a terminal device, where the terminal device includes a cache memory, and the apparatus includes:
the page static resource acquisition module is used for acquiring the page static resources sent by the server; the page static resources comprise at least one, and the version corresponding to each page static resource comprises at least one;
the generating module is used for generating a page route of each page static resource when each page static resource is stored in the cache memory;
the target page static resource acquisition module is used for acquiring the target page static resource of the latest version from the cache memory according to the page route and the data request if the data request is received after the data connection between the terminal equipment and the server is disconnected;
and the rollback module is used for rolling back the target page static resource of the latest version to the previous version from the cache memory if the target page static resource is operated to have errors.
In a third aspect, an embodiment of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the method according to the first aspect is implemented.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the method according to the first aspect.
In a fifth aspect, the present application provides a computer program product, which when run on a terminal device, causes the terminal device to execute the method of the first aspect.
Compared with the prior art, the embodiment of the application has the advantages that: when the terminal device and the server are in a data connection state, the cache memory in the terminal device can store each version of the page static resource acquired by the terminal device from the server. Based on this, when the terminal device is in an offline state and a problem occurs in using the target page static resource of the latest version, the terminal device can roll back the page static resource of the previous version directly from the cache memory according to the page route. In addition, since the cache memory is a device inside the terminal device, when the version corresponding to the static resource of the page is rolled back, the rolling back efficiency is higher.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIG. 1 is a flowchart illustrating an implementation of a method for using static resources of a page according to an embodiment of the present application;
fig. 2 is a schematic view of an application scenario in which a terminal device is in an offline state according to an embodiment of the present application;
fig. 3 is a schematic view of an application scenario in an offline state of a terminal device according to another embodiment of the present application;
FIG. 4 is a flowchart illustrating an implementation of a method for using static resources of a page according to another embodiment of the present application;
fig. 5 is a schematic diagram illustrating an implementation manner of S12 of a method for using static resources of a page according to an embodiment of the present application;
FIG. 6 is a diagram illustrating an implementation manner of S12 of a method for using static resources of a page according to another embodiment of the present application;
fig. 7 is a schematic view of an application scenario when a terminal device updates static resources of a page according to an embodiment of the present application;
FIG. 8 is a diagram illustrating an implementation manner of S12 of a method for using static resources of a page according to still another embodiment of the present application;
FIG. 9 is a flowchart illustrating an implementation of a method for using static resources of a page according to yet another embodiment of the present application;
fig. 10 is a schematic view of an application scenario in which a terminal device triggers a high-frequency usage warning according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of a page static resource utilization apparatus according to an embodiment of the present application;
fig. 12 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
The method for using the static page resources provided by the embodiment of the application can be applied to terminal devices such as mobile phones, tablet computers, notebook computers and netbooks, and the embodiment of the application does not limit the specific types of the terminal devices. The terminal equipment comprises a cache memory for storing static resources of the page. When the terminal device can establish data connection with the server, the terminal device can acquire various page static resources from the server and generate page routes of the page static resources. When the terminal equipment is in an off-line state, the corresponding page static resource can be called from the cache memory for displaying according to the page route.
Referring to fig. 1, fig. 1 is a flowchart illustrating an implementation of a method for using a static resource of a page according to an embodiment of the present application, where the method includes the following steps:
s101, terminal equipment acquires page static resources sent by a server; the page static resources comprise at least one type, and the version corresponding to each page static resource comprises at least one type.
In an embodiment, the server is a server that provides page static resources to the terminal device. When the terminal device sends a data request to the server, the server can retrieve the file corresponding to the corresponding page static resource from the server memory and return the file to the terminal device, and the terminal device analyzes the file and performs rendering display. The page static resource can be regarded as a pre-designed webpage.
In an embodiment, the terminal device may be a terminal device including any front-end website. Each page seen by the user on the front-end website is an html file (file corresponding to the static resource of the page) uploaded to the server by the developer in advance. Usually, after a developer modifies any static resource of a page, the static resource needs to be downloaded again from the server by the front-end website. At this time, for the same type of page static resource, the downloaded page static resource is the latest version of page static resource.
Generally, the page static resources included in the front-end network station are various, and each page static resource is generally updated according to the change of the service. Thus, for each page static resource, it typically has multiple versions. Based on this, for any one page static resource, if the page static resource has multiple versions, the terminal device may respectively establish a unique identifier of the page static resource of each version. The unique identification is used for distinguishing the page static resources of the multiple versions. And then, the terminal device can respectively store the association relation between each unique identifier and the corresponding version of the page static resource.
For a plurality of services of a project, each service respectively comprises a plurality of visual pages or pages for interacting with a user, and a file corresponding to each page can be regarded as a file corresponding to a page static resource.
In an embodiment, the cache memory is a memory preset by the terminal device, and is specifically a cache. Among them, a Cache memory (Cache) is a primary memory existing between a main memory and a CPU, and the Cache memory has a smaller storage capacity but a faster query speed of resources than the main memory.
S102, when each page static resource is stored in the cache memory, the terminal equipment generates a page route of each page static resource.
In an embodiment, after the terminal device obtains any page static resource, the page static resource can be stored; in addition, while storing, the terminal device may generate a page route of the page static resource, so that the terminal device may find a required page static resource for presentation according to the page route. That is, the terminal device can search and determine the corresponding page static resource from the cache memory for displaying according to the page route.
It should be noted that, for the page route corresponding to each page static resource, the terminal device may determine in advance a mapping relationship between each page route and the corresponding page static resource. And then, uniformly recording the mapping relation in a file storage list, so that the terminal equipment can search the mapping relation according to the record among the file storage lists.
S103, after the data connection between the terminal device and the server is disconnected, if a data request is received, the terminal device acquires the target page static resource of the latest version from the cache memory according to the page route and the data request.
In one embodiment, the terminal device, after acquiring the page static resource, typically stores the page static resource in the cache memory. Meanwhile, the cache memory stores a plurality of versions of page static resources. Based on this, in order to avoid display or function errors, the terminal device may determine the latest version of the page static resource as the target page static resource from among the multiple versions of the page static resource. The determining of the page static resource of the latest version from the multiple versions may specifically be: for each updated page static resource, the terminal device can give a unique identifier to distinguish the updated page static resource. That is, for the multiple versions of the page static resources, the terminal device may determine the sequence of the update corresponding to each version of the page static resources.
The terminal device processes the page static resource in an off-line state, and the processing can be realized by a service worker technology. Meanwhile, the terminal equipment can also be matched with a ceche API to realize the offline function of the data request. Specifically, the terminal device may combine the Cache API and the Service Worker technology, and dynamically read the page static resource and generate the page route after the page static resource is stored in the Cache memory of the terminal device. And then, according to the data request of the terminal equipment in the offline state, acquiring corresponding page static resources from the Cache memory through the interface function of the Cache API. Meanwhile, the Service Worker can also detect whether the stored page static resource exceeds the expiration time, and download the latest version of the page static resource from the server to update the page static resource when the expiration time is exceeded.
In an embodiment, the data request is a request initiated by the terminal device, and when the terminal device is in an offline state, the data request can be intercepted by a cache memory in the terminal device. Specifically, referring to fig. 2, fig. 2 is a schematic view of an application scenario in which a terminal device is in an offline state according to an embodiment of the present application. The client in fig. 2 is a terminal device, and when the client detects that the network condition of the client is in a weak network state or an offline state, a cache memory in the client may intercept an offline request sent by the client to a server; the cache memory may then look up the cached static resources of the target page from its own memory.
And S104, if the static resources of the running target page are wrong, the terminal equipment rolls back the static resources of the target page of the latest version to the previous version from the cache memory.
In an embodiment, if the terminal device runs the target page static resource and has an error, it indicates that the latest version of the target page static resource may have a problem of a logical code error. That is, the terminal device cannot normally display the static resources of the target page. However, at this time, the terminal device is in an offline state, and normal data connection cannot be established with the server. That is, the terminal device cannot normally obtain the static resources of the target page that can be displayed from the server.
Based on this, the terminal device already stores the rest of the version of the static resource of the target page in S101. Therefore, the terminal device can also roll back the target page static resource to the page static resource corresponding to the previous version from the cache memory.
Specifically, referring to fig. 3, fig. 3 is a schematic view of an application scenario in which a terminal device is in an offline state according to another embodiment of the present application. The client in fig. 3 is the terminal device, and the server sends the static resources of each page to the client; and then, the client stores the data in the caches respectively. And aiming at any page static resource, storing a plurality of versions of the page static resource in the cache. Specifically, as shown in fig. 3, version 1Tag, version 2Tag, and version 3 Tag. Wherein, 1Tag is the unique identifier expressed as the version mentioned in the above S101, and is used to distinguish each version. The description will be given by taking the page static resource corresponding to the version 3Tag as the target page static resource of the latest version. Under normal conditions, the client should use the static resources of the target page corresponding to the version 3Tag at the current moment. However, if the client has a logic code error while running the target page static resource, the client may roll back the target page static resource to the page static resource corresponding to the previous version (i.e. the page static resource corresponding to the version 2 Tag) directly from the cache memory.
In the conventional technique, static resources are constantly changed when a head-end network station is developed. Moreover, each time the static resource is changed, the static resource corresponding to the latest version is stored on the server, and the expiration time is usually set to be longer, for example, 1 month. Therefore, when the terminal device downloads the page static resource of the latest version and has a problem after operation, the terminal device needs to repackage and download the static resource of the previous version in the server. However, this requires not only that the terminal device be in a networked environment, but also that the server repackage and install the last version of static resources; further, the server code needs to be updated to be implemented. Therefore, it will cause the terminal device to roll back the previous version of static resource with low efficiency.
Based on this, in the present embodiment, when the terminal device is in a data connection state with the server, the cache memory in the terminal device may store the page static resources of the respective versions acquired by the terminal device from the server. Therefore, when the terminal device is in an offline state and a problem occurs in using the target page static resource of the latest version, the terminal device can roll back the page static resource of the previous version directly from the cache memory according to the page route. In addition, since the cache memory is a device inside the terminal device, when the version corresponding to the static resource of the page is rolled back, the rolling back efficiency is higher.
In one embodiment, referring to FIG. 4, after S102 generates the page route of each page static resource, the following steps S11-S12 are included, which are detailed as follows:
s11, the terminal equipment determines the expiration time of each page static resource in the cache memory.
S12, if the expiration time is exhausted, when the terminal equipment establishes data connection with the server, the terminal equipment updates the page static resource exhausted by the expiration time; otherwise, the terminal equipment maintains the expiration time of the page static resource.
In one embodiment, the expiration time is a valid time for which the static resources of the page can be used. It can be understood that if the expiration time is not exhausted, it indicates that the static resource of the page can be used by the terminal device all the time. And if the expiration time is exhausted, indicating that the static resource of the page may have been updated in the server. That is, when the terminal device calls the page static resource whose expiration time is exhausted, the fault problem of the logic code may occur.
Based on this, when the terminal device determines that the expiration time of any page static resource is exhausted, the page static resource with the exhausted expiration time can be updated when establishing data connection with the server. Otherwise, when the terminal device is still in the offline state, the terminal device needs to maintain the expiration time of the page static resource. That is, in the offline state, the terminal device may still call the static resource of the page. Therefore, the normal operation of the service corresponding to the static resource of the page can be maintained.
It is added that, although the expiration time of the page static resource has been exhausted, the latest version of the page static resource needs to be downloaded from the server. However, it may exist that the latest version of the page static resource is not published in the server. That is, in the actual case, the static resource of the page still belongs to the latest version. Only the terminal equipment is in an off-line state, and the expiration time of the static resource of the page cannot be updated in time. Based on this, in order not to affect the normal operation of the service, the terminal device may maintain the expiration time of the page static resource.
However, it should be specifically noted that, if a problem occurs in using the page static resource exhausted by the expiration time, the terminal device needs to label the page static resource. That is, at this time, the terminal device may assume that the latest version of the page static resource has already been released from the server, although the terminal device does not establish a data connection with the server. Therefore, when the terminal device is still in the offline state, the static resource of the page can be marked to be in the unavailable state in advance. Therefore, if the terminal equipment still receives the data request needing to call the page static resource in the unavailable state, the data request is directly ignored.
In one embodiment, referring to fig. 5, in the step of updating the page static resource with the expired time at S12, the following sub-steps S121-S122 are specifically implemented, which are detailed as follows:
s121, if the expiration time is exhausted, when the terminal equipment establishes data connection with a server, the terminal equipment determines whether the page static resource exhausted by the expiration time is to be used or not;
and S122, if the page static resource exhausted by the expiration time is to be used, the terminal equipment downloads the page static resource of the latest version from the server for updating.
In an embodiment, normally, when the terminal device establishes a connection with the server, the static resources of the target page to be used are determined from the cache memory; meanwhile, no matter whether the expiration time of the static resource of the target page is exhausted or not, the terminal equipment generates a first hash value corresponding to the version number of the static resource of the target page and uploads the first hash value and the data request to the server. Then, the server can compare the first hash value with a second hash value of the version number of the latest version of the static resource of the page stored in the server; if the static resources of the target page are the same, the static resources of the target page are not expired, and the server only needs to issue an unexpired response code. The terminal device may then directly use the static resource of the target page in the cache memory upon receiving the response code. Namely, the data transmission quantity between the server and the terminal device is reduced (the data sent by the server does not need to contain the latest version of the page static resource).
If the target page static resource is not the same as the target page static resource, the server sends the target page static resource of the latest version to the terminal equipment although the terminal equipment does not initiate the updating request. Based on this, for the page static resource which is not frequently used, the terminal device may set a policy that even when the expiration time is exhausted, the page static resource exhausted by the expiration time is not actively updated. And then, updating the static resource of the page only when the static resource of the page needs to be used by the terminal equipment. Therefore, the number of data interaction between the terminal equipment and the server can be reduced. The method can ensure that the frequency of data interaction between the terminal equipment and the server is reduced on the premise that the terminal equipment can normally run the service.
The first hash value may also be specifically a hash value generated according to information such as content, size, and time of the page static resource. Therefore, the server can more accurately determine whether the static resource of the page is expired or not through the first hash value.
In an embodiment, referring to fig. 6, in the step of updating the page static resource with the expired time at S12, the following sub-steps S123-S127 may be further implemented, which are detailed as follows:
s123, the terminal device generates a first hash value according to the version number corresponding to the page static resource exhausted by the expiration time.
S124, the terminal equipment uploads the first hash value to a server; the server is used for generating a second hash value of the version number of the latest version of the page static resource and comparing the second hash value with the first hash value.
In an embodiment, the first hash value is a value obtained by processing the version number according to a preset hash algorithm by the terminal device. As can be seen from the explanation in S122, when normal data interaction is performed between the terminal device and the server, the terminal device also needs to generate the first hash value of the version number of the page static resource for uploading. Based on this, it can be considered that, for each version of the page static resource, when the terminal device generates the first hash value corresponding to the version number, the terminal device stores the first hash value, so that the subsequent terminal device can call the first hash value at any time.
It should be noted that the hash algorithm preset in the terminal device should be consistent with the hash algorithm used by the server. In this way, the server can be made to determine whether the version of the page static resource stored by the terminal device is the latest version based on the same hash algorithm.
S125, the terminal equipment receives the page static resource of the latest version sent by the server; the latest version of the page static resource is issued by the server when the comparison result is determined to be different; alternatively, the first and second electrodes may be,
and S126, the terminal equipment receives the response code with the same comparison result sent by the server, wherein the response code carries new expiration time.
And S127, the terminal equipment updates the expiration time of the static page resources according to the new expiration time.
In an embodiment, after the server compares the first hash value and the second hash value, a corresponding comparison result may be generated, where the comparison result is the same result or different results. Based on this, when the server determines that the comparison result is a different result, the server may consider that the version of the page static resource stored by the terminal device at this time is not the latest version. Therefore, the server can send the page static resource of the latest version to the terminal equipment so as to update and use the terminal equipment.
Similarly, when the server determines that the comparison result is the same, the server may consider that the version of the page static resource stored by the terminal device at this time is the latest version. Therefore, the server can issue the response code to the terminal equipment. At this time, the response code is only used to indicate that the server responds to the data request of the terminal device and carries the new expiration time of the static resource of the page to the terminal device. In this embodiment, the setting form of the response code between the server and the terminal device is not limited at all. Based on this, the terminal device only needs to set the expiration time of the static resource of the page as the new expiration time. The response code may be a response code returned to 304(Not Modified).
Referring to fig. 7, fig. 7 is a schematic view of an application scenario when a terminal device updates a static resource of a page according to an embodiment of the present application. In fig. 7, cache file 1, cache file 2, and cache file 3 generally correspond to different types of page static resources. However, different types of page static resources may have different degrees of influence on the normal operation of the service. That is, whether the expiration time of the static resource of the page is exhausted may or may not affect the normal operation of the service. Based on this, different types of page static resources issued by the server may have different expiration times. Or the terminal device can actively set different expiration times for different types of page static resources. Namely expiration time 1, expiration time 2, and expiration time 3 shown in fig. 3.
Specifically, referring to fig. 8, after updating the expiration time of the page static resource according to the new expiration time S127, the terminal device may configure the expiration time of the page static resource through the following steps S128 to S130:
s128, the terminal equipment judges whether a network disconnection instruction for disconnecting the data connection with the server is received.
S129, if the network disconnection instruction is received, the terminal equipment displays the configuration information of the page static resource after disconnecting the data connection with the server; the configuration information includes information for configuring an expiration time of the static resource of the page.
S130, the terminal device configures the new expiration time according to the updating time set in the configuration information by the user.
In an embodiment, the network disconnection instruction may be an instruction generated by a user operating a terminal device, and the instruction is used to disconnect a data connection between the terminal device and a server.
It should be noted that, in the prior art, the expiration time of each page static resource cached in the cache memory is usually the expiration time of the page static resource set by the server when the server issues the page static resource to the terminal device. And, the expiration time is based on the expiration time of the strong cache setting of the Http protocol. In addition, because the Http protocol is mainly applied to the transport layer, the transport layer using the Http protocol can only provide reliable end-to-end flow control for the terminal device, thereby ensuring correct transmission of data. Therefore, in the prior art, the user cannot actively change the expiration time of the page static resource set by the server at the level of the transport layer.
However, in the present embodiment, in order to flexibly set the expiration time of each page static resource, the configuration information of each page static resource in the cache memory may be displayed when the terminal device is in an offline state. That is, the information for configuring the expiration time of the static resource of the page may be visually displayed. At this time, when the terminal device is disconnected, the technology for displaying the configuration information by the terminal device belongs to the user layer oriented use technology, and the technology does not establish end-to-end data connection with the server. Therefore, the terminal device can configure the new expiration time according to the update time set in the configuration information by the user, and the new expiration time does not belong to the change on the transport layer, so that the limitation of strong cache of the Http protocol can be avoided.
In one embodiment, referring to fig. 9, after S104 obtains the latest version of the static resource of the target page from the cache memory, the following steps S105-S106 are further included:
s105, the terminal device records the use times of each target page static resource in a preset time period.
S106, if the using times exceed the preset times, triggering high-frequency using early warning by the terminal equipment; the high-frequency usage early warning is used for developers to improve the static resources of the target page.
In one embodiment, after determining the target page static resource from the cache memory, the terminal device may also record the number of times the corresponding page static resource is used. The terminal equipment can record the use times of each target page static resource every other preset time period, and when the use times exceed the preset times, the terminal equipment triggers the high-frequency use early warning of the target page static resource so as to assist workers to improve other page static resources. The preset time period and the preset times can be preset by developers. Specifically, referring to fig. 10, fig. 10 is a schematic view of an application scenario in which the terminal device triggers the high-frequency usage early warning according to an embodiment of the present application.
Referring to fig. 11, fig. 11 is a block diagram illustrating a structure of a device for using static resources of a page according to an embodiment of the present application. The page static resource using apparatus in this embodiment includes modules for executing steps in the embodiments corresponding to fig. 1, fig. 4 to fig. 6, fig. 8, and fig. 9. Please refer to fig. 1, 4 to 6, 8 and 9 and fig. 1, 4 to 6, 8 and 9 for the corresponding embodiments. For convenience of explanation, only the portions related to the present embodiment are shown. Specifically, the page static resource using apparatus is applied to a terminal device, the terminal device includes a cache memory, and referring to fig. 11, the page static resource using apparatus 1100 may include: a page static resource obtaining module 1110, a generating module 1120, a target page static resource obtaining module 1130, and a rollback module 1140, wherein:
a page static resource obtaining module 1110, configured to obtain a page static resource sent by a server; the page static resources comprise at least one type, and the version corresponding to each page static resource comprises at least one type.
A generating module 1120, configured to generate a page route for each page static resource when storing the page static resource to the cache.
The target page static resource obtaining module 1130 is configured to, after the data connection between the terminal device and the server is disconnected, obtain, if a data request is received, the target page static resource of the latest version from the cache memory according to the page route and the data request.
A rollback module 1140, configured to roll back the latest version of the target page static resource to the previous version from the cache if the running target page static resource has an error.
In an embodiment, the page static resource using apparatus 1100 further comprises:
and the expiration time determining module is used for determining the expiration time of each page static resource in the cache.
The page static resource updating module is used for updating the page static resources exhausted by the expiration time when the terminal equipment and the server establish data connection if the expiration time is exhausted; otherwise, maintaining the expiration time of the static resources of the page.
In one embodiment, the page static resource update module is further configured to:
if the expiration time is exhausted, determining whether the page static resource exhausted by the expiration time is to be used or not when the terminal equipment establishes data connection with the server; and if the page static resource with exhausted expiration time is to be used, downloading the page static resource with the latest version from the server for updating.
In one embodiment, the page static resource update module is further configured to:
generating a first hash value according to a version number corresponding to the page static resource exhausted by the expiration time; uploading the first hash value to a server; the server is used for generating a second hash value of the version number of the latest version of the page static resource and comparing the second hash value with the first hash value; receiving the page static resource of the latest version sent by the server; the latest version of the page static resource is issued by the server when the comparison result is determined to be different; or, receiving a response code with the same comparison result sent by the server, wherein the response code carries new expiration time; and updating the expiration time of the static resources of the page according to the new expiration time.
In one embodiment, the page static resource update module is further configured to:
judging whether a network disconnection instruction for disconnecting data connection with a server is received; if a network disconnection instruction is received, displaying the configuration information of the page static resource after the data connection with the server is disconnected; the configuration information comprises information for configuring the expiration time of the static resources of the page; and configuring the new expiration time according to the updating time set in the configuration information by the user.
In an embodiment, the page static resource using apparatus 1100 further comprises:
the establishing module is used for respectively establishing the unique identifier of the page static resource of each version aiming at any page static resource; the unique identifier is used to distinguish between multiple versions of the page static resource.
In an embodiment, the page static resource using apparatus 1100 further comprises:
the recording module is used for recording the use times of each target page static resource in a preset time period;
the early warning module is used for triggering high-frequency use early warning if the use times exceed the preset times; the high-frequency usage early warning is used for developers to improve the static resources of the target page.
It should be understood that, in the structural block diagram of the page static resource using apparatus shown in fig. 11, each module is configured to execute each step in the embodiments corresponding to fig. 1, fig. 4 to fig. 6, fig. 8, and fig. 9, and each step in the embodiments corresponding to fig. 1, fig. 4 to fig. 6, fig. 8, and fig. 9 has been explained in detail in the above embodiments, and specific reference is made to fig. 1, fig. 4 to fig. 6, fig. 8, and fig. 9 and the relevant description in the embodiments corresponding to fig. 1, fig. 4 to fig. 6, fig. 8, and fig. 9, which is not repeated herein.
Fig. 12 is a block diagram of a terminal device according to an embodiment of the present application. As shown in fig. 12, the terminal apparatus 1200 of this embodiment includes: a processor 1210, a memory 1220, and a computer program 1230, such as a program for a page static resource usage method, stored in the memory 1220 and executable on the processor 1210. The processor 1210, when executing the computer program 1230, implements the steps of the various embodiments of the page static resource utilization methods described above, such as S101-S104 shown in fig. 1. Alternatively, the processor 1210, when executing the computer program 1230, implements the functions of the modules in the embodiment corresponding to fig. 11, for example, the functions of the modules 1110 to 1140 shown in fig. 11, and refer to the related description in the embodiment corresponding to fig. 11.
Illustratively, the computer program 1230 may be divided into one or more modules, which are stored in the memory 1220 and executed by the processor 1210 to implement the page static resource usage methods provided by embodiments of the present application. One or more of the modules may be a series of computer program instruction segments capable of performing certain functions, which are used to describe the execution of the computer program 1230 in the terminal device 1200. For example, computer program 1230 may implement the page static resource usage method provided by the embodiments of the present application.
Terminal apparatus 1200 can include, but is not limited to, processor 1210, memory 1220. Those skilled in the art will appreciate that fig. 12 is merely an example of a terminal device 1200 and does not constitute a limitation of terminal device 1200, and may include more or fewer components than shown, or some components in combination, or different components, e.g., the terminal device may also include input output devices, network access devices, buses, etc.
The processor 1210 may be a central processing unit, but may also be other general purpose processors, digital signal processors, application specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 1220 may be an internal storage unit of the terminal device 1200, such as a hard disk or a memory of the terminal device 1200. The memory 1220 may also be an external storage device of the terminal device 1200, such as a plug-in hard disk, a smart memory card, a flash memory card, etc. provided on the terminal device 1200. Further, the memory 1220 may also include both internal and external memory units of the terminal apparatus 1200.
The embodiment of the application provides a terminal device, which comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the computer program to implement the page static resource using method in the above embodiments.
The embodiments of the present application provide a computer-readable storage medium, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the method for using a static resource of a page as in the above embodiments is implemented.
The embodiment of the present application provides a computer program product, which, when running on a terminal device, enables the terminal device to execute the page static resource using method in the foregoing embodiments.
The above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. A method for using static resources of a page, applied to a terminal device, the terminal device including a cache memory, the method comprising:
acquiring static resources of a page sent by a server; the page static resources comprise at least one type, and the version corresponding to each page static resource comprises at least one type;
generating a page route for each of the page static resources as it is stored to the cache memory;
after the data connection between the terminal equipment and the server is disconnected, if a data request is received, acquiring a target page static resource of the latest version from the cache memory according to the page route and the data request;
and if the static resources of the target page are operated to have errors, rolling back the static resources of the target page of the latest version to the previous version from the cache memory.
2. The method for using page static resources according to claim 1, further comprising, after said generating the page route for each of said page static resources:
determining an expiration time for each of the static resources of the page in the cache;
if the expiration time is exhausted, updating the page static resources exhausted by the expiration time when the terminal equipment establishes data connection with the server; otherwise, maintaining the expiration time of the static resources of the page.
3. The method for using page static resources according to claim 2, wherein the updating the page static resources whose expiration times are exhausted comprises:
if the expiration time is exhausted, determining whether the page static resource exhausted by the expiration time is to be used or not when the terminal equipment establishes data connection with the server;
and if the page static resource exhausted by the expiration time is to be used, downloading the latest version of the page static resource from the server for updating.
4. The method for using page static resources according to claim 2, wherein the updating the page static resources whose expiration times are exhausted comprises:
generating a first hash value according to the version number corresponding to the page static resource exhausted by the expiration time;
uploading the first hash value to the server; the server is used for generating a second hash value of the version number of the latest version of the page static resource and comparing the second hash value with the first hash value;
receiving the latest version of the page static resource sent by the server; the latest version of the page static resource is issued by the server when the comparison result is determined to be different; alternatively, the first and second electrodes may be,
receiving a response code which is sent by the server and has the same comparison result, wherein the response code carries new expiration time;
and updating the expiration time of the static page resource according to the new expiration time.
5. The method for using page static resource according to claim 4, wherein after said updating the expiration time of said page static resource according to said new expiration time, further comprising:
judging whether a network disconnection instruction for disconnecting data connection with the server is received;
if the network disconnection instruction is received, displaying the configuration information of the static page resource after the data connection with the server is disconnected; the configuration information comprises information for configuring the expiration time of the page static resource;
and configuring the new expiration time according to the updating time set in the configuration information by the user.
6. The method for using page static resources according to any one of claims 1 to 5, further comprising, after obtaining the page static resources sent by the server:
aiming at any one page static resource, respectively establishing a unique identifier of the page static resource of each version; the unique identification is used for distinguishing the static resources of the pages of the multiple versions.
7. The method for using page static resources according to any of claims 1-5, further comprising, after retrieving the latest version of the target page static resource from the cache memory:
recording the use times of each static resource of the target page in a preset time period;
if the using times exceed the preset times, triggering high-frequency using early warning; and the high-frequency use early warning is used for improving the static resources of the target page by developers.
8. A page static resource usage apparatus, applied to a terminal device, the terminal device including a cache memory, the apparatus comprising:
the page static resource acquisition module is used for acquiring the page static resources sent by the server; the page static resources comprise at least one type, and the version corresponding to each page static resource comprises at least one type;
a generating module for generating a page route for each of the page static resources when storing the page static resources to the cache memory;
a target page static resource obtaining module, configured to, after a data connection between the terminal device and the server is disconnected, if a data request is received, obtain a target page static resource of a latest version from the cache memory according to the page route and the data request;
and the rollback module is used for rolling back the target page static resource of the latest version to the previous version from the cache memory if the target page static resource is operated to have errors.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 7.
CN202111439845.7A 2021-11-30 2021-11-30 Page static resource using method and device, terminal equipment and storage medium Pending CN114117280A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111439845.7A CN114117280A (en) 2021-11-30 2021-11-30 Page static resource using method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111439845.7A CN114117280A (en) 2021-11-30 2021-11-30 Page static resource using method and device, terminal equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114117280A true CN114117280A (en) 2022-03-01

Family

ID=80368146

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111439845.7A Pending CN114117280A (en) 2021-11-30 2021-11-30 Page static resource using method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114117280A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117171419A (en) * 2023-10-31 2023-12-05 腾讯科技(深圳)有限公司 Content processing method, device, electronic apparatus, storage medium, and program product
CN117171419B (en) * 2023-10-31 2024-04-30 腾讯科技(深圳)有限公司 Content processing method, device, electronic apparatus, storage medium, and program product

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117171419A (en) * 2023-10-31 2023-12-05 腾讯科技(深圳)有限公司 Content processing method, device, electronic apparatus, storage medium, and program product
CN117171419B (en) * 2023-10-31 2024-04-30 腾讯科技(深圳)有限公司 Content processing method, device, electronic apparatus, storage medium, and program product

Similar Documents

Publication Publication Date Title
US10712915B2 (en) Information presentation using a client on a terminal
CN111078147B (en) Processing method, device and equipment for cache data and storage medium
US10462250B2 (en) Distributed caching cluster client configuration
US9847907B2 (en) Distributed caching cluster management
US9753954B2 (en) Data node fencing in a distributed file system
CN111475180A (en) Method and system for updating client cache
US7237239B1 (en) Availability and consistent service semantics in a load balanced collection of services running different instances of an application
US9262323B1 (en) Replication in distributed caching cluster
US9596313B2 (en) Method, terminal, cache server and system for updating webpage data
US9529772B1 (en) Distributed caching cluster configuration
CN100461136C (en) Method and system for maintaining data coherency in multiprocessor system
WO2022222438A1 (en) Profile state synchronization method and apparatus, terminal, server, and storage medium
CN113434249A (en) Mirror image synchronization method and device, docker host and storage medium
CN114328097A (en) File monitoring method and device, electronic equipment and storage medium
CN111783005B (en) Method, device and system for displaying web page, computer system and medium
CN114398397A (en) Data processing method, device, storage medium and system
CN111031126B (en) Cluster cache sharing method, system, equipment and storage medium
CN110795495A (en) Data processing method and device, electronic equipment and computer readable medium
CN108804579B (en) Application service system and data consistency control method
CN114117280A (en) Page static resource using method and device, terminal equipment and storage medium
CN113779412B (en) Message touch method, node and system based on blockchain network
CN105338058A (en) Application updating method and device
CN104346101A (en) Dynamic storage space allocation system and method
CN107707620B (en) Method and device for processing IO (input/output) request
CN113542319A (en) Service providing entity change notification method, device and system used in Dubbo framework

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