Cache updating method, server, terminal equipment and chip system

By generating differential files on the server and sending them to the terminal device, the problem of untimely update of cached files in the terminal device is solved, and timely update of cached files and improving data processing efficiency is achieved.

CN119645942APending Publication Date: 2025-03-18HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410199842.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-08
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

After the terminal device updates the server file, the cache file is not updated in time, resulting in data processing errors.

Method used

By receiving file requests from the terminal device, the server determines whether the target file and the cache file identification match. If it does not match, it obtains the historical cache file from the server cache, generates a differential file, and sends a differential file to the terminal device to update the cache file.

Benefits of technology

It realizes timely update of cached files of terminal devices, saves network resources and transmission time, and improves data processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645942A_ABST
    Figure CN119645942A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a cache updating method, a server, terminal equipment and a chip system, which are suitable for the technical field of computers, and the method comprises the following steps: the server receives a file request sent by the terminal equipment; when the file request comprises path information and a cache file identifier, obtaining a target file from a file path indicated by the path information, the cache file identifier being a file identifier of a target cache file cached in the terminal device; when the target file is not matched with the cache file identifier, a historical cache file of the target file is obtained from a server cache, and the historical cache file conforms to the target cache file; a difference file used for describing the difference between the target file and the historical cache file is determined, the difference file is sent to the terminal device, and the difference file is used for updating the target cache file in the terminal device. According to the embodiment of the invention, the file cached by the terminal equipment can be updated in time.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the Chinese patent application submitted to the State Intellectual Property Office on September 8, 2023, with application number 202311153173.2 and application name "Cache Update Method, Server, Terminal Device and Chip System". Technical Field

[0002] The present application relates to the field of computer technology, and in particular to a cache update method, a server, a terminal device, and a chip system. Background Art

[0003] During the communication between the terminal device and the server, the terminal device can cache the file obtained from the server locally. In this way, the next time the terminal device needs to use the same file in the server, it can use the locally cached file without downloading the file from the server again, thus saving network resources used to transmit the file.

[0004] In actual applications, since the files in the server may be modified, for example, a certain data in the file is changed from A to B, if the terminal device needs to use the same file in the server next time, it still uses the locally cached file before the modification, which obviously does not match the actual situation, resulting in data processing errors. Therefore, the files cached by the terminal device need to be updated in a timely manner. Summary of the invention

[0005] In view of this, the embodiments of the present application provide a cache update method, a server, a terminal device and a chip system, which can timely update the files cached by the terminal device.

[0006] A first aspect of an embodiment of the present application provides a cache update method, which is applied to a server and includes:

[0007] The server receives a file request sent by a terminal device. Afterwards, when the file request includes path information and a cache file identifier, the server obtains the target file from the file path indicated by the path information, wherein the cache file identifier is the file identifier of the target cache file cached in the terminal device. Then, when the target file does not match the cache file identifier, the server obtains the historical cache file of the target file from the server cache, and the historical cache file matches the target cache file. Finally, the server can determine a differential file for describing the difference between the target file and the historical cache file, and send the differential file to the terminal device, wherein the differential file is used to update the target cache file in the terminal device.

[0008] The server cache is an area in the server used to cache data.

[0009] In the embodiment of the present application, for the convenience of description, the file stored in the file path in the server is recorded as the target file, the target file stored in the server cache is recorded as the historical cache file, and the target file cached in the terminal device is recorded as the target cache file.

[0010] In the embodiment of the present application, when the terminal device needs the target file in the server, it can actively send a file request to the server. In this way, the server can update the target cache file corresponding to the target file on the terminal device on demand based on the file request, so that the file cached by the terminal device can be updated in a timely and effective manner. In addition, the server determines whether the file content of the target file corresponding to the target cache file in the server has changed by using the cache file identifier, which is simple to operate and has low computational complexity, and can effectively save computing resources. In addition, in the case where the file content of the target file corresponding to the target cache file in the server has changed, the server only sends the differential file to the terminal device, that is, only sends the changed part of the content to the terminal device, which can greatly save the network resources and transmission time used for transmitting files compared to directly sending the modified complete file to the terminal device, and helps to improve the file update efficiency of the terminal device. In addition, the historical cache file matching the target cache file is cached in the server cache, so that the server can quickly and accurately determine the modified part of the target file based on the historical cache file cached by itself to obtain the differential file, which helps to improve the data processing efficiency.

[0011] As an optional embodiment of the present application, the server may generate a differential file when it is determined that the target file does not match the cache file identifier. The server may also generate a differential file when it is determined that the content of the target file has been modified.

[0012] It is understandable that the embodiment of the present application does not specifically limit the timing of generating the differential file. In practice, the server usually uses a file differential algorithm to perform differential processing on the target file and the historical cache file corresponding to the target file to obtain a differential file.

[0013] As an optional embodiment of the present application, the server may use a preset file difference algorithm to process the target file and the historical cache file to obtain a difference file. The preset file difference algorithm may be a preset file difference algorithm, such as a Myers difference algorithm, a BSDiff difference algorithm, etc. It can be immediately understood that the preset file difference algorithm is a file difference algorithm supported by the terminal device.

[0014] As an optional embodiment of the present application, when the file request includes an algorithm identifier of a file differential algorithm supported by the terminal device, the server can use the file differential algorithm supported by the terminal device to perform differential processing on the target file and the historical cache file to obtain the above-mentioned differential file.

[0015] In the embodiment of the present application, since the file difference algorithm used by the server and the file merging algorithm used by the terminal device need to be compatible with each other, and since the file difference algorithms supported by different terminal devices may be different, the server uses the file difference algorithm supported by the terminal device to obtain the difference file, which can enable the terminal device to accurately and effectively merge the difference file with the target cache file to obtain the content of the target file, thereby achieving accurate and effective update of the target cache file. As an example, the file merging algorithm can be a combine algorithm.

[0016] In some application scenarios, since file difference and file merging are two inverse processes, the compatible file difference algorithm and file merging algorithm can be two components of the same algorithm. For example, the file difference algorithm includes both a solution for performing difference processing on files and a solution for merging using difference files.

[0017] It is understandable that the terminal device may support one or more file differential algorithms. When the terminal device supports multiple file differential algorithms, the server may use one of the file differential algorithms to perform differential processing on the target file and the historical cache file to obtain the above differential file. When the terminal device supports multiple file differential algorithms, when the server returns the differential file to the terminal device, it may also return the target algorithm identifier, so that the terminal device can update the target cache file with a matching file merge algorithm, thereby enabling the terminal device to accurately and effectively update the target cache file, wherein the target algorithm identifier is used to indicate the target file differential algorithm used by the server. Among them, the target file differential algorithm is the file differential algorithm used by the server.

[0018] As an optional embodiment of the present application, the method further includes: when the file request includes path information but does not include a cache file identifier, obtaining the target file from the file path indicated by the path information, and sending the target file to the terminal device.

[0019] In the embodiment of the present application, when the file request includes path information but does not include a cache file identifier, it indicates that the target cache file corresponding to the path information has not been cached in the terminal device. When the server receives a file request and the file request does not include a cache file identifier, it can directly obtain the required target file from the file path indicated by the path information and send the target file to the terminal device.

[0020] It is understandable that when the terminal device receives the target file under the path information for the first time, it can use the target file and cache the file as a target cache file for next use.

[0021] As an optional embodiment of the present application, after sending the target file to the terminal device, the server stores the target file in the server cache to obtain a historical cache file of the target file.

[0022] In an embodiment of the present application, after sending the target file to the terminal device, the server stores the target file in the server cache, so that when the content of the target file in the server changes, the historical cache file in the server cache can be used to obtain the differential file of the target file, thereby improving the data processing speed.

[0023] In a first possible implementation manner of the first aspect, after determining a differential file for describing the difference between the target file and the historical cache file, and sending the differential file to the terminal device, the method further includes: switching the historical cache file to the target file.

[0024] In an embodiment of the present application, after the content of the target file changes, the server can use the historical cache file to obtain the differential file, and update the historical cache file to ensure that the historical cache file cached in the server is the same as the updated target cache file on the terminal device, thereby ensuring that the target cache file on the terminal device can be accurately and effectively updated subsequently.

[0025] In a second possible implementation manner of the first aspect, the method further includes: when the file request includes differential information for indicating that the terminal device supports the differential update mode, the server determines that the terminal device supports the differential update mode. And when the target file does not match the cache file identifier, the server obtains the historical cache file of the target file from the server cache, including: when the target file does not match the cache file identifier and the terminal device supports the differential update mode, the server obtains the historical cache file from the server cache.

[0026] In the embodiment of the present application, if the target file does not match the cache file identifier, it means that the content of the target file has changed. The server obtains the historical cache file from the server cache to generate a differential file only when the content of the target file has changed and the terminal device supports the differential update mode, and then sends the differential file to the terminal device, so that the terminal device updates the target cache file based on the differential file, which helps to accurately and effectively update the target cache file cached by the terminal device.

[0027] As an optional embodiment of the present application, when the target file does not match the cache file identifier and the terminal device does not support the differential update mode, the server sends the target file to the terminal device.

[0028] In an embodiment of the present application, when the content of the target file changes and the terminal device does not support the differential update mode, the server directly sends the target file to the terminal device, so that the terminal device can use the target file to replace and update the target cache file.

[0029] As an optional embodiment of the present application, when the target file matches the cache file identifier and the terminal device does not support the differential update mode, the server returns information to the terminal device indicating that there is no need to update the target cache file.

[0030] In the embodiment of the present application, the target file matches the cache file identifier, indicating that the content of the target file has not changed. If the content of the target file has not changed and the terminal device does not support the differential update mode, the server sends information to the terminal device indicating that the target cache file does not need to be updated, so that the terminal device does not update the target cache file.

[0031] As an optional embodiment of the present application, when the target file matches the cache file identifier and the terminal device supports the differential update mode, the server returns information to the terminal device indicating that there is no need to update the target cache file.

[0032] In an embodiment of the present application, when the content of the target file has not changed and the terminal device supports the differential update mode, the server sends information to the terminal device indicating that the target cache file does not need to be updated, so that the terminal device does not update the target cache file.

[0033] In the embodiment of the present application, regardless of whether the terminal device supports the differential update mode, the server can effectively respond to the file request of the terminal device, has good compatibility, and can ensure that the terminal device updates the target cache file in a timely and effective manner.

[0034] As an optional embodiment of the present application, the information used to indicate that the target cache file does not need to be updated is a second status code. The second status code is used to indicate that the target cache file does not need to be updated. When the transmission protocol between the terminal device and the server is Hypertext Transfer Protocol (HTTP), the second status code is usually "304".

[0035] In a third possible implementation of the first aspect, the method further includes: when the target file does not match the cache file identifier and the terminal device does not support the differential update mode, the server sends a first status code and the target file to the terminal device, wherein the first status code is used to instruct the terminal device to replace and update the target cache file based on the target file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the first status code is usually "200".

[0036] In an embodiment of the present application, when the content of the target file has changed and the terminal device does not support the differential update mode, the server sends a first status code and the target file to the terminal device, which can enable the terminal device to quickly and accurately know the operations to be performed, thereby helping to speed up the efficiency of the terminal device in updating the target cache file.

[0037] It should be noted that since the size of the status code is usually very small, the network resources required to transmit the status code are very small. Therefore, by instructing the terminal device to perform different operations through different status codes, the efficiency of the terminal device in updating the target cache file can be improved while saving network resources.

[0038] It is understandable that when the terminal device does not support the differential update mode, after the server sends the target file to the terminal device, it is not necessary to cache the target file in the server cache, so that unnecessary consumption of storage resources can be reduced.

[0039] In a fourth possible implementation manner of the first aspect, the method further includes: when the target file matches the cache file identifier, the server returns a second status code to the terminal device, wherein the second status code is used to indicate that the target cache file does not need to be updated.

[0040] In an embodiment of the present application, when the content of the target file has not changed, the server returns a second status code to the terminal device to indicate that the terminal device does not need to update the target cache file. This allows the terminal device to quickly and accurately learn of the operations that need to be performed, thereby helping to speed up the efficiency of the terminal device in updating the target cache file.

[0041] In a fifth possible implementation manner of the first aspect, the file request may include differential information for indicating that the terminal device supports the differential update mode, and the differential information includes an algorithm identifier of a file differential algorithm supported by the terminal device.

[0042] In the embodiment of the present application, when the file request includes an algorithm identifier, it indicates that the terminal device supports the differential update mode. The algorithm identifier can reflect that the terminal device supports the differential update mode and can also reflect the specific file differential algorithm supported by the terminal device. Compared with using another piece of information to reflect that the terminal device supports the differential update mode, the amount of data carried by the file request can be effectively reduced, which helps to further save network resources.

[0043] As an optional embodiment of the present application, the differential information is a differential field in the file request, and the value of the differential field is an algorithm identifier of a file differential algorithm supported by the terminal device.

[0044] It is understandable that the value of the difference field can be empty or not. In some application scenarios, if the value of the difference field is empty, the server can use a certain file difference algorithm by default. In other application scenarios, if the value of the difference field is not empty, the server can use the file difference algorithm indicated by any algorithm identifier in the difference field.

[0045] In a sixth possible implementation of the first aspect, the server sending the differential file to the terminal device includes: sending the differential file and at least one of the following information to the terminal device: a third status code, a file identifier of the target file, and a target algorithm identifier. The target algorithm identifier is used to indicate the target file differential algorithm used by the server, and the third status code is used to indicate that the terminal device updates the target cache file based on the differential file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the third status code may be "310".

[0046] In an embodiment of the present application, the server may send one or more of the following three items: a third status code, a file identifier of a target file, and a target algorithm identifier, while sending a differential file to a terminal device. The server sends the file identifier of the target file to the terminal device, and the terminal device uses the file identifier to verify whether the updated target cache file is accurate and valid. The server sends the target algorithm identifier to the terminal device, which may instruct the terminal device to use a suitable file merge algorithm to update the target cache file, so that the terminal device can quickly and accurately update the target cache file, thereby improving the update efficiency and accuracy. The server sends the third status code to the terminal device, which enables the terminal device to quickly and accurately know the operations to be performed, thereby helping to speed up the efficiency of the terminal device in updating the target cache file.

[0047] It can be understood that after the terminal device receives the file identifier of the target file returned by the server, the cache file identifier can be updated using the obtained file identifier, and specifically the cache file identifier can be switched to the file identifier of the received target file. In this way, it is convenient for the terminal device to subsequently update the target cache file based on the updated cache file identifier.

[0048] In a seventh possible implementation of the first aspect, before the server receives a file request sent by a terminal device, the method further includes: when the target file has a target template file, the server stores the target template file as a historical cache file of the target file in the server cache. And the server sends a differential file to the terminal device, including: when the server determines that the terminal device has the target template file, the server sends a third status code and a differential file to the terminal device. When the server determines that the terminal device does not have the target template file, the server sends a fourth status code, the target template file, and the differential file to the terminal device. Among them, the fourth status code is used to instruct the terminal device to update the target cache file based on the differential file and the target template file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the fourth status code can be "311".

[0049] In an embodiment of the present application, when the target file has a target template file, it is indicated that the target file is a file generated by relying on the target template file. Since the template file usually does not change, the server stores the target template file as a historical cache file of the target file in the server cache, which can avoid repeated updates of the historical cache file, thereby reducing the amount of data processing and improving data processing efficiency while ensuring accurate and effective updates of the target cache file on the terminal device. In addition, when the terminal device does not have the target template file, the target template file and the differential file are sent to the terminal device at the same time, and when the terminal device has the target template file, only the differential file is sent to the terminal device, which can reduce unnecessary data transmission, thereby improving the overall data processing efficiency. In addition, by instructing the terminal device to perform different operations through different status codes, the terminal device can quickly and accurately know the operations to be performed, which helps to speed up the efficiency of the terminal device in updating the target cache file.

[0050] As an optional embodiment of the present application, the server may determine that the terminal device has the target template file after sending the target template file of the target file to the terminal device for the first time. The server may determine that the terminal device does not have the target template file before sending the target template file of the target file to the terminal device for the first time.

[0051] A second aspect of an embodiment of the present application provides a cache update method, which is applied to a terminal device, and the method includes:

[0052] The terminal device sends a file request to the server, the file request includes path information and a cache file identifier, and the cache file identifier is a file identifier of a target cache file cached in the terminal device. Afterwards, the terminal device can receive request result data returned by the server for the file request, and the request result data includes at least one of the following: a differential file and a target template file of the target file, wherein the differential file is obtained by the server using any method of the first aspect, and the target file is a file in the server corresponding to the path information. Finally, the terminal device can update the target cache file according to the request result data.

[0053] In the embodiment of the present application, when the terminal device needs the target file in the server, it can actively send a file request to the server. In this way, the server can update the target cache file corresponding to the target file on the terminal device on demand based on the file request, so that the file cached by the terminal device can be updated in a timely and effective manner. In addition, the server determines whether the file content of the target file corresponding to the target cache file in the server has changed by using the cache file identifier, which is simple to operate and has low computational complexity, and can effectively save computing resources. In addition, in the case where the file content of the target file corresponding to the target cache file in the server has changed, the server only sends the differential file to the terminal device, that is, only sends the changed part of the content to the terminal device, which can greatly save the network resources and transmission time used for transmitting files compared to directly sending the modified complete file to the terminal device, and helps to improve the file update efficiency of the terminal device. In addition, the historical cache file matching the target cache file is cached in the server cache, so that the server can quickly and accurately determine the modified part of the target file based on the historical cache file cached by itself to obtain the differential file, which helps to improve the data processing efficiency.

[0054] As an optional embodiment of the present application, the terminal device updates the target cache file according to the request result data, which may include: when the request result data includes a differential file, the terminal device updates the target cache file based on the differential file. When the request result data includes a differential file and a target template file, the terminal device updates the target cache file based on the differential file and the target template file.

[0055] In an embodiment of the present application, when the target file has a target template file, if the request result data returned by the server to the terminal device does not include the target template file, it usually means that the server has already sent the target template file to the terminal device. At this time, the terminal device can use the existing target template file and the received differential file to update the target cache file, which can save unnecessary network resource consumption while ensuring that the terminal device updates the target cache file in a timely and accurate manner.

[0056] It can be understood that, in the case that the target file does not have a target template file, the terminal device can use the differential file to update the target cache file when receiving the differential file.

[0057] As an optional embodiment of the present application, the terminal device can use a file merging algorithm compatible with the target file difference algorithm to merge the difference file and the target cache file to obtain an updated target cache file. It can be understood that the updated target cache file is consistent with the target file content.

[0058] The target file difference algorithm is usually a file difference algorithm used by the server, for example, it can be a Myers difference algorithm, a BSDiff difference algorithm, and the like.

[0059] In the embodiment of the present application, since the file difference algorithm used by the server and the file merging algorithm used by the terminal device need to be adapted to each other, the terminal device adopts a file merging algorithm that is adapted to the target file difference algorithm to merge the difference file and the target cache file. This allows the terminal device to accurately and effectively merge the difference file with the target cache file to obtain the content of the target file, thereby achieving accurate and effective updating of the target cache file.

[0060] In a first possible implementation of the second aspect, when the request result data also includes a status code, the terminal device updates the target cache file according to the request result data, which may include: when the request result data includes a differential file and the status code is a third status code, the terminal device updates the target cache file based on the differential file. When the request result data includes a differential file and a target template file, and the status code is a fourth status code, the terminal device updates the target cache file based on the differential file and the target template file.

[0061] In the embodiment of the present application, the request result data includes a status code, that is, the server instructs the terminal device to perform a corresponding operation through the status code, so that the terminal device can quickly and accurately know the operation to be performed, which helps to speed up the efficiency of the terminal device in updating the target cache file. In addition, since the size of the status code is usually very small, the network resources required to transmit the status code are very small. Therefore, by instructing the terminal device to perform different operations through different status codes, the efficiency of the terminal device in updating the target cache file can be improved while saving network resources.

[0062] As an optional embodiment of the present application, when the request result data includes a status code, the target cache file is updated according to the request result data, including: when the status code is a second status code, the target cache file is not updated.

[0063] In a second possible implementation manner of the second aspect, the request result data further includes at least one of the following: a file identifier of a target file corresponding to the path information in the server, and a target algorithm identifier.

[0064] The target algorithm identifier is used to indicate the target file difference algorithm used by the server.

[0065] In the embodiment of the present application, when the request result data includes a file identifier, the terminal device can use the file identifier to verify whether the updated target cache file is accurate and valid. In addition, when the request result data includes a target algorithm identifier, the terminal device can quickly and accurately use a file merging algorithm that is compatible with the target file difference algorithm to update the target cache file, which can improve the update efficiency and accuracy.

[0066] It can be understood that after the terminal device receives the file identifier of the target file returned by the server, the cache file identifier can be updated using the obtained file identifier, and specifically the cache file identifier can be switched to the file identifier of the received target file. In this way, it is convenient for the terminal device to subsequently update the target cache file based on the updated cache file identifier.

[0067] In a third possible implementation manner of the second aspect, the method further includes: when the request result data includes the target template file, storing the target cache file and the target template file in correspondence with each other.

[0068] Among them, the target template file is the template file corresponding to the target file.

[0069] In the embodiment of the present application, since the template file is usually stable and unchanged, the terminal device stores the target template file of the target file, which can avoid repeated transmission of the same file and help save network resources.

[0070] A third aspect of an embodiment of the present application provides a cache update device, the device comprising:

[0071] A request receiving unit, used for receiving a file request sent by a terminal device;

[0072] A file acquisition unit, configured to acquire a target file from a file path indicated by the path information when a file request includes path information and a cache file identifier, wherein the cache file identifier is a file identifier of a target cache file cached in a terminal device;

[0073] A cache acquisition unit, used to acquire a historical cache file of the target file from the server cache when the target file does not match the cache file identifier, the historical cache file being consistent with the target cache file;

[0074] The file sending unit is used to determine a differential file for describing the difference between the target file and the historical cache file, and send the differential file to the terminal device, wherein the differential file is used to update the target cache file in the terminal device.

[0075] As an embodiment of the present application, the cache update device can implement any method of the first aspect described above.

[0076] A fourth aspect of an embodiment of the present application provides a cache update device, the device comprising:

[0077] A request sending unit, used to send a file request to a server, the file request including path information and a cache file identifier, the cache file identifier being a file identifier of a target cache file cached in a terminal device;

[0078] A file receiving unit, configured to receive request result data returned by the server for the file request, wherein the request result data includes at least one of the following: a differential file and a target template file of a target file, wherein the differential file is obtained by the server by processing using the method of any one of the first aspects above, and the target file is a file in the server corresponding to the path information;

[0079] The file updating unit is used to update the target cache file according to the request result data.

[0080] As an embodiment of the present application, the cache update device can implement any method of the second aspect described above.

[0081] In a fifth aspect, an embodiment of the present application provides a server, comprising a memory, a processor, a communication interface, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method as described in any one of the above-mentioned first aspects is implemented.

[0082] In a sixth aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, a communication interface, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method as described in any one of the second aspects above is implemented.

[0083] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the method as described in any one of the first aspects above, or implements the method as described in any one of the second aspects above.

[0084] In an eighth aspect, an embodiment of the present application provides a chip system, the chip system includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement any method of the first aspect or any method of the second aspect. The chip system can be a single chip or a chip module composed of multiple chips.

[0085] In a ninth aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on a terminal device, the terminal device executes any method of the first aspect or any method of the second aspect.

[0086] It can be understood that the beneficial effects of the third to ninth aspects mentioned above can be found in the relevant descriptions of the first and second aspects mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0087] Figure 1 A schematic diagram of a process of interaction between a server and a terminal device provided in an embodiment of the present application;

[0088] Figure 2 An interactive flow chart of a cache update method provided in an embodiment of the present application;

[0089] Figure 3 A flowchart of an implementation of a server responding to a file request provided in an embodiment of the present application;

[0090] Figure 4 A schematic diagram of a process for executing a cache update method by a server provided in an embodiment of the present application;

[0091] Figure 5A A schematic diagram of a target template file provided in an embodiment of the present application;

[0092] Figure 5B A schematic diagram of a target file provided in an embodiment of the present application;

[0093] Figure 6 A schematic diagram of a process for updating a target cache file by a terminal device provided in an embodiment of the present application;

[0094] Figure 7 A schematic diagram of a process for updating a target cache file by another terminal device provided in an embodiment of the present application;

[0095] Figure 8 A schematic diagram of another process of interaction between a server and a terminal device provided in an embodiment of the present application;

[0096] Fig. 9 A schematic diagram of the structure of a cache updating device in a server provided in an embodiment of the present application;

[0097] Fig.10 A schematic diagram of the structure of a cache updating device in a terminal device provided in an embodiment of the present application;

[0098] Fig.11 A schematic diagram of the structure of a server provided in an embodiment of the present application;

[0099] Fig.12 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0100] Fig.13 A schematic diagram of the structure of a mobile phone provided in an embodiment of the present application. DETAILED DESCRIPTION

[0101] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0102] The following are some concepts that may be involved in the embodiments of the present application:

[0103] Multiple: Unless otherwise specified, in the embodiments of the present application, multiple refers to two or more.

[0104] Path information: In the embodiment of the present application, the path information is usually the information carried in the file request, and the path information can indicate the file path or file address of a certain file in the server. The path information can be a Uniform Resource Locator (URL). The URL address usually includes a protocol name, a domain name, and a file path.

[0105] In practice, when a terminal device requests a file from a server through a file request, since the file request carries the path information of the file, the server can find the file required by the terminal device from the server based on the file request.

[0106] Target file: In the embodiment of the present application, the target file is usually a file stored in the server. The file path of the target file is the same as the file path indicated by the path information in the file request.

[0107] Historical cache files: In the embodiment of the present application, historical cache files are usually target files cached in the server cache, wherein the server cache is usually an area in the server for caching data.

[0108] In practice, after the server sends the target file to the terminal device, the target file can be cached in the server cache for backup. In addition, after the server sends the differential file to the terminal device, the server can replace and update the historical cache file, so that the server can always cache the same content of the target file as the terminal device, that is, the historical cache file in the server cache and the target cache file in the terminal device can be updated synchronously, so that the server can determine the differential file between the target file and the target cache file with the historical cache file in the server cache.

[0109] Target cache file: In the embodiment of the present application, the target cache file is usually a target file cached in the terminal device.

[0110] In practice, after the terminal device obtains the target file from the server for the first time, the target file can be cached so that the cached target cache file can be used for corresponding processing later. In order to distinguish the description, the target file cached in the terminal device can be referred to as the target cache file. When the target file in the server is modified, the target cache file needs to be synchronously updated.

[0111] Cache file identifier: In the embodiment of the present application, the cache file identifier generally refers to the file identifier of the target cache file.

[0112] Real-time file identification: In the embodiment of the present application, the real-time file identification generally indicates the file identification of the target file.

[0113] File identification: In the embodiment of the present application, the file identification is usually information generated by the server for identifying the file. The file identification can be the first secure hash algorithm value (Secure Hash Algorithm 1, SHA-1) of the file, or the fifth message digest algorithm value (Message-Digest Algorithm 5, MD5) of the file, etc. It can be understood that the embodiment of the present application does not specifically limit the form of the file identification.

[0114] In some application scenarios, the terminal device may also generate a file identifier. For example, in some application scenarios, the terminal device may also generate a cache file identifier for the target cache file. It is understandable that in this application scenario, the algorithm used by the server to generate the file identifier and the algorithm used by the terminal device to generate the file identifier should be the same algorithm, for example, both are MD5 algorithms, or both are SHA-1 algorithms, etc.

[0115] Differential file: In the embodiment of the present application, the differential file is generally a file used to describe the difference between the target file and the historical cache file.

[0116] File difference algorithm: In the embodiment of the present application, the file difference algorithm is generally an algorithm for determining the difference between two files, that is, the file difference algorithm can be used to determine the difference file between two files. As an example, the file difference algorithm can be a Myers difference algorithm, a BSDiff difference algorithm, etc.

[0117] In practical applications, the file difference algorithm used by the server and the file merging algorithm used by the terminal device need to be compatible with each other.

[0118] In some application scenarios, since file difference and file merging are two inverse processes, the compatible file difference algorithm and file merging algorithm can be two components of the same algorithm, that is, the compatible file difference algorithm and file merging algorithm can be the same algorithm. For example, the file difference algorithm includes both a solution for performing difference processing on files and a solution for performing merging processing using difference files.

[0119] To further illustrate, if the target file is F0, the historical cache file is F1, the target cache file is F2, and the server uses file differential algorithm 1 to determine the differential file between F0 and F1, since F1 and F2 are consistent, that is, the contents of F1 and F2 are consistent, the terminal device can use file differential algorithm 1 to merge the differential file with F2 to obtain the content of the target file.

[0120] Transmission protocol: In the embodiment of the present application, the terminal device usually accesses the server through a browser. The transmission protocols supported by the browser may include but are not limited to: HTTP protocol, Secure Hypertext Transfer Protocol (HTTPS), File Transfer Protocol (FTP), Simple Mail Transfer Protocol (SMTP), etc.

[0121] In an embodiment of the present application, taking the transmission protocol between the terminal device and the server as the HTTP protocol as an example, when the transmission protocol between the terminal device and the server is the HTTP protocol, the file request is an HTTP request, that is, the file request is a request that complies with the HTTP protocol format.

[0122] Status code: When a terminal device sends a request to a server, the server can return a status code to the terminal device to indicate the request result.

[0123] Taking the HTTP protocol as an example, if the status code returned by the server to the terminal device is 200, it means that the request response is successful; if the status code returned by the server to the terminal device is 304, it means that the requested resource is the same as the local cache resource, and so on.

[0124] Target template file: In the embodiment of the present application, the target template file is generally a template file based on which the target file is generated. As an example, when the target file is a table file, the template file of the target file can be a table template.

[0125] Differential update mode: In the embodiment of the present application, the differential update mode is generally a mode that supports updating the target cache file with a differential file.

[0126] During the communication between the terminal device and the server, the terminal device can cache the file obtained from the server locally. In this way, the next time the terminal device needs to use the same file in the server, it can use the locally cached file without downloading the file from the server again, thus saving network resources used to transmit the file.

[0127] For example, if the terminal device obtains file 1 from the server, the terminal device can cache file 1 locally. In this way, the next time the terminal device needs to use file 1 from the server, it can use the locally cached file 1 without downloading file 1 from the server again, thereby avoiding network resource consumption caused by repeated downloading of file 1.

[0128] In actual applications, since the files in the server may be modified, for example, a certain data in file 1 in the server is changed from A to B, if the terminal device needs to use the same file in the server next time, it still uses the locally cached file before the modification, which obviously does not match the actual situation, resulting in data processing errors. Therefore, the files cached by the terminal device need to be updated in a timely manner.

[0129] In order to solve the above technical problem of untimely update of cache files on terminal devices, an optional approach is that when the terminal device needs to use the same file in the server next time, if the file in the server has not been modified since the server last sent the file to the terminal device until the current request time, the server can instruct the terminal device to continue to use the locally cached file; if the file in the server has been modified since the server last sent the file to the terminal device until the current request time, the server can instruct the terminal device to download the file again. The details of this solution are as follows:

[0130] Figure 1 A schematic diagram of the process of interaction between a server and a terminal device provided in an embodiment of the present application. It can be understood that Figure 1 The situation shown in the figure is that the transmission protocol between the terminal device and the server is the HTTP protocol. This is just an example. The embodiment of the present application does not limit the specific type of the transmission protocol between the terminal device and the server.

[0131] Figure 1 From top to bottom, it shows situation 1 where the terminal device requests the target file from the server for the first time, situation 2 where the terminal device requests the target file from the server again and the target file has not been modified, and situation 3 where the terminal device requests the target file from the server again and the target file has been modified.

[0132] Scenario 1: The terminal device requests the target file from the server for the first time. In Scenario 1, the terminal device sends a file request to the server, the server returns the target file to the terminal device, and the terminal device caches the target file returned by the server. In order to distinguish the description, the target file cached in the terminal device is called a target cache file.

[0133] Scenario 2: The terminal device requests the target file from the server again and the target file has not been modified. In Scenario 2, the terminal device sends a file request to the server again, and the server indicates that the target file in the server has not been modified, and the terminal device can use the target cache file in the cache.

[0134] Scenario 3: The terminal device requests the target file from the server again and the target file has been modified. In Scenario 3, the terminal device sends a file request to the server again, and the server returns the modified target file to the terminal device. The terminal device uses the received modified target file to replace and update the target cache file.

[0135] Figure 1 In the illustrated situation 1, GET / config.json HTTP1.1 in the file request indicates that the file request complies with the 1.1 version of the HTTP protocol, and the path of the target file to be obtained is: config.json. Host xxx.com indicates that the domain name is: xxx.com. In addition, in the content returned by the server to the terminal device, HTTP1.1 200OK indicates that the server responded successfully. Content-length:10240 indicates that the size of the content returned by the server is 10240 bytes, or 10K bytes. Cache-control:max-age=0 indicates that the valid duration of the file is 0, which means that the file needs to be retrieved each time it is used. etag:"8dff5414cbfdcb1f05a" indicates that the identifier of the target file is: 8dff5414cbfdcb1f05a. In addition, Figure 1 The dotted arrow in indicates that the terminal device downloads the target file from the server.

[0136] Figure 1 In the illustrated scenario 2, if-None-Match: "8dff5414cbfdcb1f05a" in the file request indicates that the identifier of the target cache file is matched with the identifier of the target file in the server. In scenario 2, since the content of the target file in the server has not been modified, at this time, in the content returned by the server to the terminal device, HTTP1.1 304NotModified indicates that the requested resource is the same as the local cache resource, and the content of the target file in the server has not changed. At this time, the size of the content returned by the server to the terminal device is 0, and the terminal device can directly use the locally cached target cache file for processing.

[0137] Figure 1 In the illustrated scenario 3, the content of the target file in the server has been modified, specifically, the value of the "name" field in the target file has changed from A to B. At this time, the server returns the modified target file to the terminal device, and the value of etag in the content returned by the server to the terminal device has changed from 8dff5414cbfdcb1f05a to 649141cf4149f2345, that is, the server returns the identifier of the modified target file to the terminal device. At this time, the size of the content returned by the server to the terminal device is 10240 bytes.

[0138] Combination Figure 1 It can be seen that although the above scheme can achieve timely updating of the cache files on the terminal device to a certain extent, when the target file in the server is modified, the server needs to return the entire modified target file to the terminal device. When the target file is very large, the required network resources will be very large, and the time required to transfer the file will also be very long, resulting in a long time to complete the update of the target cache file on the terminal device, resulting in reduced timeliness of updating the target cache file on the terminal device.

[0139] In view of the above-mentioned technical problems existing in the related art, in order to timely update the cache file on the terminal device, in an embodiment of the present application, the server receives a file request sent by the terminal device. Afterwards, when the file request includes path information and a cache file identifier, the server obtains the target file from the file path indicated by the path information, wherein the cache file identifier is the file identifier of the target cache file cached in the terminal device. Then, when the target file does not match the cache file identifier, the server obtains the historical cache file of the target file from the server cache, and the historical cache file matches the target cache file. Finally, the server can determine a differential file for describing the difference between the target file and the historical cache file, and send the differential file to the terminal device, wherein the differential file is used to update the target cache file in the terminal device.

[0140] The embodiments of the present application have at least the following beneficial effects:

[0141] 1. When the terminal device needs the target file in the server, it can actively send a file request to the server. In this way, the server can update the target cache file corresponding to the target file on the terminal device on demand based on the file request, so as to achieve timely and effective update of the files cached by the terminal device.

[0142] 2. The server determines whether the file content of the target file corresponding to the target cache file in the server has changed through the cache file identifier. The operation is simple and the calculation complexity is low, which can effectively save computing resources.

[0143] 3. When the file content of the target file corresponding to the target cache file in the server changes, the server only sends the differential file to the terminal device, that is, only sends the changed part of the content to the terminal device. Compared with directly sending the modified complete file to the terminal device, it can greatly save the network resources and transmission time used for transmitting files, which helps to improve the file update efficiency of the terminal device.

[0144] 4. Cache historical cache files that match the target cache files in the server cache, so that the server can quickly and accurately determine the modified parts of the target file based on the historical cache files in its own cache to obtain differential files, which helps to improve data processing efficiency.

[0145] The embodiments of the present application may be applicable to a scenario in which a terminal device updates a cached file after obtaining the file from a server and caching the file.

[0146] The cache update method provided in the embodiment of the present application can be applied to a terminal device or a server, that is, the terminal device or the server can be the execution subject of the cache update method provided in the embodiment of the present application. Among them, the terminal device can be a mobile phone, a tablet computer, a wearable device, etc., and the server can be a desktop computer, a network server, an embedded device, etc. The embodiment of the present application does not specifically limit the specific types of the terminal device and the server.

[0147] The following uses the HTTP protocol as an example of the transmission protocol between the terminal device and the server to illustrate the solution of the embodiment of the present application.

[0148] Figure 2 An interactive flow chart of the cache update method provided in an embodiment of the present application.

[0149] Step 201: The terminal device sends a file request to the server.

[0150] File requests are usually used to request files. File requests usually include path information of the requested target file, which can indicate the file path or file address of the target file in the server. In this way, the server can find the target file required by the terminal device based on the file request. In practice, the path information is usually a URL address, and the server can use the URL address to find the target file required by the terminal device.

[0151] The terminal device can maintain communication connection with the server through wireless communication technology or wired communication technology. When the terminal device needs to use a file in the server, the terminal device can send a file request to the server through the network to obtain the file.

[0152] It is understandable that the file request may also include other information, such as identification information of the terminal device, a timestamp, etc. In addition, if a historical version of the file to be obtained is cached in the terminal device, the file request may also include a file identifier of the historical version file.

[0153] In the embodiment of the present application, in order to distinguish the description, the file stored in the file path in the server is recorded as the target file, the target file stored in the server cache is recorded as the historical cache file, and the target file cached in the terminal device is recorded as the target cache file. That is to say, when the target cache file has been cached in the terminal device, the file request may also include the file identifier of the target cache file.

[0154] In addition, for ease of description, the file identifier of the target cache file can be recorded as the cache file identifier. The cache file identifier is usually information generated by the server to identify the target cache file. As an example, the cache file identifier can be the SHA-1 value of the target cache file, or it can be the MD5 value of the target cache file. It can be understood that the embodiment of the present application does not specifically limit the form of the cache file identifier.

[0155] In practice, the server can send the generated cache file identifier to the terminal device, so that the terminal device can use the file identifier to indicate whether the terminal device has cached the corresponding file the next time it sends a file request for the same file. In addition, in some application scenarios, the terminal device can also generate a cache file identifier. For example, after receiving the target file returned by the server, the terminal device can record the received target file as the target cache file and generate a cache file identifier for the target cache file.

[0156] In addition, the file request may also include differential information for indicating that the terminal device supports the differential update mode. In this way, after receiving the file request, the server can quickly and accurately determine whether the terminal device supports the differential update mode. The differential update mode generally refers to a mode of using differential files to perform file updates.

[0157] Step 202: The server receives a file request.

[0158] In the embodiment of the present application, the server may receive a file request sent by a terminal device. After receiving the file request, the server may analyze the content of the file request to determine a response solution.

[0159] The following is an illustrative description of the server's response process using steps 203 to 206 as an example.

[0160] Step 203: When the file request includes the path information and the cache file identifier, the server determines whether the target file matches the cache file identifier.

[0161] In an embodiment of the present application, the server can find the target file from the file path indicated by the path information. Afterwards, the server can calculate the file identifier of the target file. For ease of description, the file identifier of the target file can be recorded as a real-time file identifier. Afterwards, the server can compare the real-time file identifier with the cache file identifier to determine whether the target file matches the cache file identifier. Specifically, if the real-time file identifier is consistent with the cache file identifier, it is considered that the target file matches the cache file identifier, and if the real-time file identifier is inconsistent with the cache file identifier, it is considered that the target file does not match the cache file identifier.

[0162] It is understandable that when the server finds the target file, it calculates the file identifier of the target file, which is only an exemplary description. In some application scenarios, the file identifier of the target file can also be generated when the target file is modified. In other words, the embodiment of the present application does not specifically limit the timing of generating the file identifier of the target file.

[0163] It is understandable that the server may use a message digest algorithm or other algorithms to generate a file identifier for the file. As an example, the message digest algorithm may be an MD5 algorithm, a SHA-1 algorithm, or the like.

[0164] Step 204: If the target file does not match the cache file identifier, the server obtains the historical cache file of the target file from the server cache.

[0165] Among them, the historical cache file is the target file cached in the server cache. In practice, after the server sends the target file to the terminal device, the target file can be cached in the server cache for backup. In addition, after the server sends the differential file to the terminal device, the server can use the target file to replace and update the historical cache file, so that the server can always cache the same content as the terminal device, that is, both cache the latest target file content. In practice, the historical cache file in the server cache is synchronously updated with the target cache file in the terminal device, which can facilitate the server to determine the differential file between the target file and the target cache file with the historical cache file in the server cache.

[0166] The server cache is usually an area in the server used to cache files.

[0167] In the case where the target file does not match the cache file identifier, the server may obtain a historical cache file corresponding to the target file from the server cache.

[0168] In practice, the server can find the historical cache file from the server cache in a variety of ways. As an example, the server can use the file name of the target file to find the historical cache file from the server cache. As another example, the server can also use the file identifier of the target file to find the historical cache file from the server cache. As yet another example, the server can also use the device identifier of the terminal device, the file name of the target file, and the file identifier of the target file, at least two of the three to find the historical cache file from the server cache. The embodiments of the present application do not specifically limit how to find the historical cache file from the server cache.

[0169] Step 205: The server determines a differential file between the historical cache file and the target file.

[0170] The differential file is usually used to describe the difference between the historical cache file and the target file. That is, the differential file can describe the modified content part of the target file.

[0171] As an optional embodiment of the present application, the server may use a preset file difference algorithm to process the target file and the historical cache file to obtain a difference file for describing the difference between the target file and the historical cache file. The preset file difference algorithm may be a pre-set file difference algorithm, such as a Myers difference algorithm, a BSDiff difference algorithm, etc. It can be immediately understood that the preset file difference algorithm is a file difference algorithm supported by the terminal device.

[0172] As an optional embodiment of the present application, the file request may include an algorithm identifier of a file difference algorithm supported by the terminal device. At this time, the server may use the file difference algorithm supported by the terminal device to process the target file and the historical cache file to obtain the above difference file.

[0173] In the embodiment of the present application, since the file difference algorithm used by the server and the file merging algorithm used by the terminal device need to be adapted to each other, and since the file difference algorithms supported by different terminal devices may differ, the server uses the file difference algorithm supported by the terminal device to obtain the difference file, so that the terminal device can accurately and effectively merge the difference file with the target cache file to obtain the content of the target file, thereby achieving accurate and effective updating of the target cache file.

[0174] In some application scenarios, since file difference and file merging are two inverse processes, the compatible file difference algorithm and file merging algorithm can be two components of the same algorithm. For example, the file difference algorithm includes both a solution for performing difference processing on files and a solution for merging using difference files.

[0175] It is understandable that the terminal device may support one or more file differential algorithms. When the terminal device supports multiple file differential algorithms, the server may use one of the file differential algorithms to perform differential processing on the target file and the historical cache file to obtain the above differential file. When the terminal device supports multiple file differential algorithms, when the server returns the differential file to the terminal device, it may also return the target algorithm identifier, so that the terminal device can update the target cache file with a matching file merge algorithm, thereby enabling the terminal device to accurately and effectively update the target cache file, wherein the target algorithm identifier is used to indicate the target file differential algorithm used by the server. Among them, the target file differential algorithm is the file differential algorithm used by the server.

[0176] It should be noted that the server can generate a differential file when it is determined that the target file does not match the cache file identifier. The server can also generate a differential file when it is determined that the content of the target file has been modified. It can be understood that the embodiment of the present application does not specifically limit the timing of generating the differential file.

[0177] Step 206: The server sends the differential file to the terminal device.

[0178] After obtaining the differential file of the target file, the server may send the differential file to the terminal device, so that the terminal device may use the differential file to timely update the target cache file.

[0179] It can be understood that after the terminal device updates the target cache file, it can use the updated target cache file.

[0180] It is understandable that when the server sends the differential file to the terminal device, it can also send other information to the terminal device, such as a timestamp, a file identifier of the target file, and a target algorithm identifier, etc. The target algorithm identifier is used to indicate the target file differential algorithm used by the server.

[0181] In the embodiment of the present application, the server sends the file identifier of the target file to the terminal device, and the terminal device uses the file identifier to verify whether the updated target cache file is accurate and valid. In addition, the server sends the target algorithm identifier to the terminal device, which can instruct the terminal device to use an adaptive file merging algorithm to update the target cache file, so that the terminal device can quickly and accurately update the target cache file, which can improve the update efficiency and accuracy.

[0182] It can be understood that after the terminal device receives the file identifier of the target file returned by the server, the cache file identifier can be updated using the obtained file identifier, and specifically the cache file identifier can be switched to the file identifier of the received target file. In this way, it is convenient for the terminal device to subsequently update the target cache file based on the updated cache file identifier.

[0183] As an optional embodiment of the present application, the above steps 203 to 206 can be replaced by the following steps: when the file request includes path information but does not include a cache file identifier, the server obtains the target file from the file path indicated by the path information and sends the target file to the terminal device.

[0184] Here, when the cache file identifier is not included in the file request, it means that the terminal device is downloading the target file from the server for the first time, and the target cache file corresponding to the path information has not been cached in the terminal device. When the server receives the file request and the file request does not include the cache file identifier, it can directly obtain the required target file from the file path indicated by the path information, and send the target file to the terminal device.

[0185] It can be understood that when the terminal device receives the target file corresponding to the path information for the first time, it can use the target file and cache the file as a target cache file for next use.

[0186] As an optional embodiment of the present application, after sending the target file to the terminal device, the server stores the target file in the server cache to obtain a historical cache file of the target file.

[0187] In an embodiment of the present application, after sending the target file to the terminal device, the server stores the target file in the server cache. When the content of the target file in the server changes, the historical cache file in the server cache can be used to obtain the differential file of the target file, thereby improving the data processing speed.

[0188] As an optional embodiment of the present application, the above steps 203 to 206 can be replaced by the following steps: when the file request includes path information and a cache file identifier, if the target file matches the cache file identifier, the server returns information to the terminal device indicating that there is no need to update the target cache file.

[0189] Here, after the server receives the file request, if the target file matches the cache file identifier, it means that the target file in the server has not been modified. At this time, the target cache file in the terminal device does not need to be updated, and the server can return information to the terminal device indicating that the target cache file does not need to be updated.

[0190] It is understandable that when the terminal device receives information indicating that the target cache file does not need to be updated, it can directly use the locally cached target cache file. The terminal device directly uses the locally cached target cache file for processing, which can save network resources and time, and help improve the overall data processing efficiency between the server and the terminal device.

[0191] As an optional embodiment of the present application, the information used to indicate that the target cache file does not need to be updated is a second status code. The second status code is used to indicate that the target cache file does not need to be updated. When the transmission protocol between the terminal device and the server is the HTTP protocol, the second status code is usually "304".

[0192] In the embodiment of the present application, the server instructs the terminal device to perform corresponding operations through the status code, so that the terminal device can quickly and accurately know the operations to be performed, which helps to speed up the efficiency of the terminal device in updating the target cache file. In addition, since the size of the status code is usually very small, the network resources required for transmitting the status code are very small. Therefore, by instructing the terminal device to perform different operations through different status codes, the efficiency of the terminal device in updating the target cache file can be improved while saving network resources.

[0193] Considering that the target file may be a file obtained by relying on a target template file, that is, the target file may correspond to a target template file. Among them, the target template file is usually a template file based on which the target file is generated. As an example, when the target file is a table file, the template file of the target file can be a table template.

[0194] In addition, considering that template files usually do not change, when the target file has a target template file, the server can use the target template file of the target file as the historical cache file of the target file. In this way, there is no need to repeatedly update the historical cache file, and it is possible to reduce the amount of data processing and improve data processing efficiency while ensuring accurate and effective updates of the target cache file on the terminal device.

[0195] As an optional embodiment of the present application, in the case where the target file corresponds to a target template file, the above steps 203 to 206 can be replaced by the following steps 301 and 302.

[0196] Figure 3 A flowchart of an implementation of a server responding to a file request provided in an embodiment of the present application.

[0197] Step 301: The server determines whether the terminal device has a target template file of the target file.

[0198] Here, since the terminal device originally does not have the target template file of the target file, that is, if the terminal device has the target template file, it usually means that the server has sent the target template file to the terminal device. Conversely, if the terminal device does not have the target template file, it means that the server has never sent the target template file to the terminal device, or has not sent the target template file to the terminal device within a certain effective period.

[0199] As an optional embodiment of the present application, after the server sends the target template file of the target file to the terminal device for the first time, it is determined that the terminal device has the target template file. Before the server sends the target template file of the target file to the terminal device for the first time, it is determined that the terminal device does not have the target template file.

[0200] In the embodiment of the present application, the server determines whether the terminal device has the target template file of the target file based on whether it has sent the target template file to the terminal device. The implementation process is simple and helps to improve data processing efficiency.

[0201] As an optional embodiment of the present application, after the server sends the target template file of the target file to the terminal device, the terminal device can return a label to the server, and the server can associate the label with the target template file. In this way, the server can determine whether the terminal device has the target template file based on the label.

[0202] As another optional embodiment of the present application, the server may inquire whether the terminal device currently has the target template file of the target file. If the terminal device returns information indicating that it has the target template file, the server may determine that the terminal device has the target template file.

[0203] As another optional embodiment of the present application, when the terminal device sends a file request to the server, the terminal device may carry indication information in the file request to indicate whether there is a target template file for the target file. In this way, the server can determine whether the terminal device has the target template file for the target file based on the indication information in the file request.

[0204] Step 302: When the terminal device has the target template file, the server sends the differential file to the terminal device.

[0205] Step 303: When the terminal device does not have the target template file, the server sends the target template file and the differential file to the terminal device.

[0206] In an embodiment of the present application, when the terminal device does not have the target template file, the target template file and the differential file are sent to the terminal device at the same time, and when the terminal device has the target template file, there is no need to send the target template file to the terminal device, which can reduce unnecessary data transmission and improve the overall data processing efficiency.

[0207] Step 207: The server updates the historical cache file.

[0208] In the case where the target file is modified, the server may switch the historical cache file to the target file, that is, replace the content of the historical cache file with the same content as the target file.

[0209] In an embodiment of the present application, after the content of the target file changes, the server can use the historical cache file to obtain the differential file, and update the historical cache file to ensure that the historical cache file cached in the server matches the updated target cache file on the terminal device, thereby ensuring that the target cache file on the terminal device can be accurately and effectively updated subsequently.

[0210] Considering that the size of the status code is usually small, the network resources required to transmit the status code are very small. By instructing the terminal device to perform different operations through different status codes, the efficiency of the terminal device in updating the target cache file can be improved while saving network resources.

[0211] As an optional embodiment of the present application, when the file request includes path information but does not include a cache file identifier, the server obtains the target file from the file path indicated by the path information, and sends the target file and a first status code to the terminal device. The first status code is used to instruct the terminal device to replace and update the target cache file based on the target file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the first status code is usually "200".

[0212] As an optional embodiment of the present application, when the target file matches the cache file identifier, the server returns a second status code to the terminal device, wherein the second status code is used to indicate that there is no need to update the target cache file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the second status code is usually "304".

[0213] In an embodiment of the present application, when the content of the target file has not changed, the server returns a second status code to the terminal device to indicate that the terminal device does not need to update the target cache file. This allows the terminal device to quickly and accurately learn of the operations that need to be performed, thereby helping to speed up the efficiency of the terminal device in updating the target cache file.

[0214] As an optional embodiment of the present application, when the target file does not have a target template file, the server sends a differential file to the terminal device, including: sending a third status code and a differential file to the terminal device. The third status code is used to instruct the terminal device to update the target cache file based on the differential file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the third status code can be "310".

[0215] As an optional embodiment of the present application, when the target file has a target template file, the server sends a differential file to the terminal device, including: when it is determined that the terminal device has the target template file, the server sends a third status code and a differential file to the terminal device, and when it is determined that the terminal device does not have the target template file, the server sends a fourth status code, the target template file and the differential file to the terminal device. The fourth status code is used to instruct the terminal device to update the target cache file based on the differential file and the target template file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the fourth status code can be "311".

[0216] In the embodiment of the present application, when the terminal device does not have the target template file, the server sends the target template file and the differential file to the terminal device at the same time, and when the terminal device has the target template file, the server does not need to send the target template file to the terminal device, which can reduce unnecessary data transmission, thereby improving the overall data processing efficiency. In addition, by instructing the terminal device to perform different operations through different status codes, the terminal device can quickly and accurately know the operations to be performed, which helps to speed up the efficiency of the terminal device in updating the target cache file.

[0217] Figure 2 and Figure 3 This is an example of the default terminal device supporting the differential update mode. However, in actual applications, it is found that not all terminal devices can support the differential update mode. In order to improve the compatibility of the solution, the server needs to be able to quickly and accurately distinguish whether the terminal device currently communicating supports the differential update mode.

[0218] In order to enable the server to better identify whether the terminal device supports the differential update mode, the file request sent by the terminal device that supports the differential update mode may include differential information for indicating that the terminal device supports the differential update mode. In this way, the server can determine whether the terminal device supports the differential update mode by the presence or absence of differential information in the file request. Specifically, if the file request includes differential information, it means that the terminal device supports the differential update mode, and if it does not include differential information, it means that the terminal device does not support the differential update mode.

[0219] In the case where the file request carries differential information, the above step 204 can be replaced by the following step: when the server supports differential update mode on the terminal device and the target file does not match the cache file identifier, the historical cache file is obtained from the server cache.

[0220] In the embodiment of the present application, if the target file does not match the cache file identifier, it means that the content of the target file has changed. The server obtains the historical cache file from the server cache to generate a differential file only when the content of the target file has changed and the terminal device supports the differential update mode, and then sends the differential file to the terminal device, so that the terminal device updates the target cache file based on the differential file, which helps to accurately and effectively update the target cache file cached by the terminal device.

[0221] As an optional embodiment of the present application, the file request may include differential information for indicating that the terminal device supports the differential update mode, and the differential information includes an algorithm identifier of a file differential algorithm supported by the terminal device.

[0222] In the embodiment of the present application, when the file request includes an algorithm identifier, it indicates that the terminal device supports the differential update mode. The algorithm identifier can reflect both that the terminal device supports the differential update mode and the file differential algorithm supported by the terminal device. Compared with using another piece of information to reflect that the terminal device supports the differential update mode, the amount of data carried by the file request can be effectively reduced, which helps to further save network resources.

[0223] As an optional embodiment of the present application, the differential information is a differential field in the file request, and the value of the differential field is an algorithm identifier of a file differential algorithm supported by the terminal device.

[0224] It is understandable that the value of the difference field can be empty or not. In some application scenarios, if the value of the difference field is empty, the server can use a certain file difference algorithm by default. In other application scenarios, if the value of the difference field is not empty, the server can use the file difference algorithm indicated by any algorithm identifier in the difference field.

[0225] In the embodiment of the present application, regardless of whether the terminal device supports the differential update mode, the server can effectively respond to the file request of the terminal device, with good compatibility, and can ensure that the terminal device updates the target cache file in a timely and effective manner. The following is an exemplary description of the server's response action in combination with different application scenarios.

[0226] Application scenario A: The target file does not match the cache file identifier and the terminal device does not support the differential update mode. In this application scenario, the server can send the target file to the terminal device.

[0227] In the embodiment of the present application, if the target file does not match the cache file identifier, it means that the content of the target file has changed. If the content of the target file has changed and the terminal device does not support the differential update mode, the server directly sends the target file to the terminal device, so that the terminal device can use the target file to replace and update the target cache file.

[0228] As an optional embodiment of the present application, in application scenario A, the server may send a first status code to the terminal device while sending the target file to the terminal device. The first status code is used to instruct the terminal device to replace and update the target cache file based on the target file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the first status code is usually "200". Since the size of the status code is usually very small, the network resources required to transmit the status code are very small. Therefore, by instructing the terminal device to perform different operations through different status codes, the efficiency of the terminal device in updating the target cache file can be improved while saving network resources.

[0229] It is understandable that when the terminal device does not support the differential update mode, after the server sends the target file to the terminal device, it is not necessary to cache the target file in the server cache, so that unnecessary consumption of storage resources can be reduced.

[0230] Application scenario B: The target file matches the cache file identifier and the terminal device does not support the differential update mode. In this application scenario, the server can return information to the terminal device indicating that the target cache file does not need to be updated.

[0231] In the embodiment of the present application, the target file matches the cache file identifier, indicating that the content of the target file has not changed. If the content of the target file has not changed and the terminal device does not support the differential update mode, the server sends information to the terminal device indicating that the target cache file does not need to be updated, so that the terminal device does not update the target cache file.

[0232] Application scenario C: the target file matches the cache file identifier and the terminal device supports the differential update mode. In this application scenario, the server can return information indicating that the target cache file does not need to be updated to the terminal device.

[0233] In an embodiment of the present application, when the content of the target file has not changed and the terminal device supports the differential update mode, the server sends information to the terminal device indicating that the target cache file does not need to be updated, so that the terminal device does not update the target cache file.

[0234] As an optional embodiment of the present application, in application scenarios B and C, the information used to indicate that the target cache file does not need to be updated is the second status code, and the second status code is used to indicate that the target cache file does not need to be updated. When the transmission protocol between the terminal device and the server is the HTTP protocol, the second status code is usually "304".

[0235] Application scenario D: The target file does not match the cache file identifier and the terminal device supports the differential update mode. In this application scenario, the server can send the differential file to the terminal device.

[0236] As an optional embodiment of the present application, in application scenario D, the server may send a third status code to the terminal device while sending the differential file to the terminal device. The third status code is used to indicate that the terminal device updates the target cache file based on the differential file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the third status code may be "310".

[0237] Considering that the target file may also have a target template file, and the terminal device may also have cached the target template file of the target file, the above application scenario D can be further subdivided into application scenario D1, application scenario D2 and application scenario D3.

[0238] Application scenario D1, the target file does not have a target template file, the target file does not match the cache file identifier, and the terminal device supports the differential update mode. In this application scenario, the server can send a differential file to the terminal device. Optionally, the server can also send a third status code to the terminal device at the same time.

[0239] Application scenario D2, the target file has a target template file, the terminal device has a target template file, the target file does not match the cache file identifier, and the terminal device supports the differential update mode. In this application scenario, the server can send a differential file to the terminal device.

[0240] As an optional embodiment of the present application, in application scenario D2, the server may also send a third status code to the terminal device at the same time. The third status code is used to instruct the terminal device to update the target cache file based on the differential file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the third status code may be "310".

[0241] Application scenario D3, the target file has a target template file, the terminal device does not have the target template file, the target file does not match the cache file identifier, and the terminal device supports the differential update mode. In this application scenario, the server can send the differential file and the target template file to the terminal device.

[0242] As an optional embodiment of the present application, in application scenario D3, the server may also send a fourth status code to the terminal device at the same time. The fourth status code is used to instruct the terminal device to update the target cache file based on the differential file and the target template file. When the transmission protocol between the terminal device and the server is the HTTP protocol, the fourth status code may be "311".

[0243] Further references Figure 4 , Figure 4 This is a schematic diagram of the process of executing the cache update method provided by the server in the embodiment of the present application. It can be understood that Figure 4 The situation shown in the figure is that the transmission protocol between the terminal device and the server is the HTTP protocol, that is, the file request is an HTTP request, and the response made by the server to the file request of the terminal device is an HTTP response. This is just an example. The embodiment of the present application does not limit the specific type of the transmission protocol between the terminal device and the server.

[0244] Step 401: The server receives a file request sent by a terminal device.

[0245] In step 402, the server determines whether the terminal device supports the differential update mode through the information carried in the file request. If it does, step 404 is executed; if it does not, step 403 is executed.

[0246] Step 403: The web service in the server responds to the file request. The web service is a service in the server for responding to HTTP requests.

[0247] It should be noted that step 402 and step 404 to step 416 are all executed by the extended cache service. The extended cache service is usually an intermediate service between the terminal device and the server. In some application scenarios, the extended cache service can be another service or process running in the server independent of the web service. In other application scenarios, the extended cache service may not run in the server, for example, it can run in an electronic device outside the server.

[0248] Step 404: The server determines whether the file request carries a cache file identifier. If so, step 405 is executed; if not, step 416 is executed.

[0249] In step 405, the server determines whether the target file has changed. If the target file has changed, step 406 is executed; otherwise, if the target file has not changed, step 415 is executed.

[0250] Here, if the target file has changed, it means that the target file has been modified. The server can determine whether the target file has changed by comparing the file identifier of the target file with the cache file identifier.

[0251] Step 406, the server determines whether the target file supports extended caching. If yes, step 407 is executed; if no, step 414 is executed.

[0252] In the embodiment of the present application, since the differential update mode needs to consume server cache resources and the capacity of the server cache is limited, differential processing is only performed on files that support extended cache, so that the terminal device can be updated in differential update mode, which can achieve flexible processing of various files.

[0253] It should be noted that the files supporting the extended cache are usually some pre-set files, for example, they may be configuration files of the application.

[0254] Step 407, the server determines whether the historical cache file is the target template file. If it is the target template file, step 408 is executed; if it is not the target template file, step 409 is executed.

[0255] It should be noted that, when a target file corresponds to a target template file, the server usually directly caches the target template file of the target file locally, which can avoid always updating the historical cache file.

[0256] Step 408: The server generates a differential file.

[0257] Here, in the case where the historical cache file is the target template file, the server may perform a differential operation between the target template file and the target file to obtain a differential file.

[0258] Figure 5A A schematic diagram of a target template file provided in an embodiment of the present application. Figure 5B A schematic diagram of a target file provided in an embodiment of the present application. Figure 5A and Figure 5B In the illustrated scenario, the content of the differential file generated by the server may be: (Zhang San, male, 23, Loess Plateau).

[0259] Step 409: When the historical cache file is not the target template file, the server generates a differential file and updates the historical cache file locally cached by the server.

[0260] In practice, the server can directly replace the historical cache file with the target file to update the historical cache file.

[0261] Step 410: The server returns the status code 310 and the differential file to the terminal device.

[0262] Step 411, the server determines whether the terminal device has cached the target template file. If the terminal device has cached the target template file, step 413 is executed; if the terminal device has not cached the target template file, step 412 is executed.

[0263] Step 412: The server returns the status code 311, the differential file and the target template file to the terminal device.

[0264] Step 413: The server returns the status code 310 and the differential file to the terminal device.

[0265] Step 414: The server returns a status code 200 and a target file to the terminal device.

[0266] Step 415: The server returns status code 304 to the terminal device.

[0267] Step 416: The server returns a status code 200 and the target file to the terminal device.

[0268] The operation details, principles and beneficial effects of steps 401 to 416 can all be referred to in the above Figure 1-Figure 3 The relevant descriptions of the corresponding embodiments are not repeated here.

[0269] Step 208: The terminal device receives the request result data returned by the server in response to the file request.

[0270] The request result data includes at least one of the following: a differential file, and a target template file of the target file.

[0271] In practice, the request result data also includes at least one of the following: a file identifier of a target file corresponding to the path information in the server, and a target algorithm identifier.

[0272] The target algorithm identifier is used to indicate the target file difference algorithm used by the server.

[0273] In the embodiment of the present application, when the request result data includes a file identifier, the terminal device can use the file identifier to verify whether the updated target cache file is accurate and valid. In addition, when the request result data includes a target algorithm identifier, the terminal device can quickly and accurately use a file merging algorithm that is compatible with the target file difference algorithm to update the target cache file, which can improve the update efficiency and accuracy.

[0274] It can be understood that after the terminal device receives the file identifier of the target file returned by the server, the cache file identifier can be updated using the obtained file identifier, and specifically the cache file identifier can be switched to the file identifier of the received target file. In this way, it is convenient for the terminal device to subsequently update the target cache file based on the updated cache file identifier.

[0275] After receiving the request result data, the terminal device may analyze the request result data to determine an update plan.

[0276] The following is an illustrative description of the process of updating the target cache file by the terminal device by taking step 209 as an example.

[0277] Step 209: The terminal device updates the target cache file based on the request result data.

[0278] Figure 6 The present invention provides a schematic diagram of a process for updating a target cache file by a terminal device according to an embodiment of the present invention. Figure 6 As shown, the terminal device can update the target cache file by executing the following steps 601 to 602.

[0279] Step 601: When the request result data includes a differential file, the terminal device updates the target cache file based on the differential file.

[0280] Step 602: When the request result data includes a differential file and a target template file, the terminal device updates the target cache file based on the differential file and the target template file.

[0281] In an embodiment of the present application, when the target file has a target template file, if the request result data returned by the server to the terminal device does not include the target template file, it usually means that the server has already sent the target template file to the terminal device. At this time, the terminal device can use the existing target template file and the received differential file to update the target cache file, which can save unnecessary network resource consumption while ensuring that the terminal device updates the target cache file in a timely and accurate manner.

[0282] It can be understood that, in the case that the target file does not have a target template file, the terminal device can use the differential file to update the target cache file when receiving the differential file.

[0283] As an optional embodiment of the present application, the terminal device can use a file merging algorithm compatible with the target file difference algorithm to merge the difference file and the target cache file to obtain an updated target cache file. It can be understood that the updated target cache file is consistent with the target file content.

[0284] The target file difference algorithm is usually a file difference algorithm used by the server, for example, it can be a Myers difference algorithm, a BSDiff difference algorithm, and the like.

[0285] In the embodiment of the present application, since the file difference algorithm used by the server and the file merging algorithm used by the terminal device need to be adapted to each other, the terminal device adopts a file merging algorithm that is adapted to the target file difference algorithm to merge the difference file and the target cache file. This allows the terminal device to accurately and effectively merge the difference file with the target cache file to obtain the content of the target file, thereby achieving accurate and effective updating of the target cache file.

[0286] As an optional embodiment of the present application, when the request result data includes a target template file, the terminal device may store the target cache file and the target template file in correspondence with each other.

[0287] Among them, the target template file is the template file corresponding to the target file.

[0288] In the embodiment of the present application, since the template file is usually stable and unchanged, the terminal device stores the target template file of the target file, which can avoid repeated transmission of the same file and help save network resources.

[0289] Considering that the server usually instructs the terminal device to perform different operations through different status codes when responding to the file request of the terminal device, when the request result data includes the status code, steps 601-602 can be replaced by the following steps 701 to 702. Figure 7 Another schematic diagram of a process for updating a target cache file by a terminal device provided in an embodiment of the present application is described in detail as follows:

[0290] Step 701: When the request result data includes a differential file and the status code is a third status code, the terminal device updates the target cache file based on the differential file.

[0291] Step 702: When the request result data includes a differential file and a target template file, and the status code is a fourth status code, the terminal device updates the target cache file based on the differential file and the target template file.

[0292] In the embodiment of the present application, the request result data includes a status code, that is, the server instructs the terminal device to perform a corresponding operation through the status code, so that the terminal device can quickly and accurately know the operation to be performed, which helps to speed up the efficiency of the terminal device in updating the target cache file. In addition, since the size of the status code is usually very small, the network resources required to transmit the status code are very small. Therefore, by instructing the terminal device to perform different operations through different status codes, the efficiency of the terminal device in updating the target cache file can be improved while saving network resources.

[0293] As an optional embodiment of the present application, the terminal device does not update the target cache file when the status code is the second status code.

[0294] Further references Figure 8 , Figure 8 A schematic diagram of another process of interaction between a server and a terminal device provided in an embodiment of the present application.

[0295] Figure 8 This article takes the example of requesting a configuration file, i.e., the config.json file, every time a terminal device starts an application. Figure 8 As you can see, the file size of the config.json file is 10K bytes, which is understandable. Figure 8 The situation shown in the figure is that the transmission protocol between the terminal device and the server is the HTTP protocol. This is just an example. The embodiment of the present application does not limit the specific type of the transmission protocol between the terminal device and the server.

[0296] Figure 8 From top to bottom, the following are respectively shown: Scenario 1, where the terminal device requests the target file from the server for the first time; Scenario 2, where the terminal device requests the target file from the server again and the target file has not been modified; and Scenario 3, where the terminal device requests the target file from the server again and the target file has been modified. Figure 8 It can be seen that the server can respond to the file request of the terminal device 1 that does not support the differential update mode, and can also respond to the file request of the terminal device 2 that supports the differential update mode, that is, the cache update method provided in the embodiment of the present application has good compatibility. The details are as follows:

[0297] Scenario 1: The terminal device requests the target file from the server for the first time.

[0298] Specifically, the terminal device 1 sends a file request to the server, the server returns the target file to the terminal device 1, and the terminal device 1 caches the target file returned by the server. In order to distinguish the description, the target file cached in the terminal device is called a target cache file.

[0299] The terminal device 2 sends a file request to the server, and the file request carries differential information for indicating the file differential algorithm supported by the terminal device 2. The server returns the target file to the terminal device 2, and the terminal device 2 caches the target file returned by the server. At the same time, the server itself also caches the target file. In order to distinguish the description, the target file cached in the server can be recorded as a historical cache file.

[0300] like Figure 8 As shown, in scenario 1, the GET / config.json HTTP1.1 in the file request of terminal device 1 indicates that the file request follows the HTTP protocol version 1.1, and the path of the target file to be obtained is: config.json. Hostxxx.com indicates that the domain name is: xxx.com. In addition, in the content returned by the server to the terminal device, HTTP1.1 200OK indicates that the server responded successfully. Content-length:10240 indicates that the size of the content returned by the server is 10240 bytes, that is, 10K bytes. Cache-control:max-age=0 indicates that the effective length of the file is 0, that is, the file needs to be retrieved each time it is used. etag:"8dff5414cbfdcb1f05a" indicates that the identifier of the target file is: 8dff5414cbfdcb1f05a.

[0301] The file request of terminal device 2 has one more information than the file request of terminal device 1: Diff: algorithm = merys, bsdiff, which means that terminal device 2 can support two file difference algorithms, namely myers difference algorithm and bsdiff difference algorithm.

[0302] Figure 8 The dotted arrows in indicate that both terminal device 1 and terminal device 2 download the target file from the server.

[0303] Scenario 2: The terminal device requests the target file from the server again and the target file has not been modified.

[0304] Specifically, the terminal device 1 sends a file request to the server again, and the server indicates that the target file in the server has not been modified, and the terminal device 1 can use the target cache file in the cache.

[0305] The terminal device 2 sends a file request to the server again, and the server indicates that the target file in the server has not been modified, and the terminal device 2 can use the target cache file in the cache.

[0306] Figure 8In the illustrated scenario 2, if-None-Match: "8dff5414cbfdcb1f05a" in the file request indicates that the identifier of the target cache file is matched with the identifier of the target file in the server. In scenario 2, since the content of the target file in the server has not been modified, at this time, in the content returned by the server to the terminal device 1, HTTP1.1 304NotModified indicates that the requested resource is the same as the local cache resource, and the content of the target file in the server has not changed. At this time, the size of the content returned by the server to the terminal device 1 is 0, and the terminal device 1 can directly use the locally cached target cache file for processing.

[0307] from Figure 8 It can be seen that in scenario 2, the server's response to terminal device 1 is the same as the server's response to terminal device 2.

[0308] Scenario 3: The terminal device requests the target file from the server again and the target file has been modified.

[0309] Specifically, the terminal device 1 sends a file request to the server again, and the server returns the modified target file to the terminal device. The terminal device uses the received modified target file to replace and update the target cache file.

[0310] Terminal device 2 sends a file request to the server again, and the server uses the target file and the historical cache file in the local cache to perform a differential operation to obtain a differential file. After that, the server returns the differential file to terminal device 2. After that, terminal device 2 can merge the differential file with the target cache file in the local cache of the terminal device to obtain a modified target file. Finally, the terminal device can replace and update the target cache file with the modified target file obtained by merging.

[0311] Combination Figure 8 In scenario 3, the content of the target file in the server has been modified. Specifically, the value of the "name" field in the target file has changed from A to B.

[0312] At this time, after receiving the file request from terminal device 1, the server can return the modified target file to terminal device 1, and the value of etag in the content returned by the server to terminal device 1 changes from 8dff5414cbfdcb1f05a to 649141cf4149f2345, that is, the server returns the identifier of the modified target file to terminal device 1. In addition, the length of the content returned by the server to terminal device 1 is 10240 bytes.

[0313] In scenario 3, after receiving the file request from terminal device 1, the server can first perform a differential operation between the target file and the historical cache file in the local cache to obtain the differential file patch.txt, and then return patch.txt to terminal device 2. The size of patch.txt is 23. At this time, the length of the content returned by the server to terminal device 2 is only 23 bytes, which can greatly reduce the amount of data required to be transmitted and the transmission time, and can timely update the cache file on the terminal device.

[0314] Corresponding to the cache update method in the above embodiment, Fig. 9 A schematic diagram of the structure of a cache update device in a server provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0315] Reference Fig. 9 , the cache updating device comprises:

[0316] The request receiving unit 901 is used to receive a file request sent by a terminal device;

[0317] A file acquisition unit 902, configured to acquire a target file from a file path indicated by the path information when the file request includes path information and a cache file identifier, wherein the cache file identifier is a file identifier of a target cache file cached in a terminal device;

[0318] The cache acquisition unit 903 is used to acquire a historical cache file of the target file from the server cache when the target file does not match the cache file identifier, and the historical cache file matches the target cache file;

[0319] The file sending unit 904 is used to determine a differential file for describing the difference between the target file and the historical cache file, and send the differential file to the terminal device, wherein the differential file is used to update the target cache file in the terminal device.

[0320] As an embodiment of the present application, the cache update device can implement the following Figure 1-Figure 8 The illustrated embodiments and other related method embodiments.

[0321] The process of each module in the cache update device provided in the embodiment of the present application realizing its own function can be specifically referred to the aforementioned Figure 1-Figure 8 The description of the illustrated embodiment and other related method embodiments will not be repeated here.

[0322] Corresponding to the cache update method in the above embodiment, Fig.10 A schematic diagram of the structure of a cache update device in a terminal device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0323] Reference Fig.10 , the cache updating device comprises:

[0324] The request sending unit 1001 is used to send a file request to the server, where the file request includes path information and a cache file identifier, where the cache file identifier is a file identifier of a target cache file cached in the terminal device;

[0325] The file receiving unit 1002 is used to receive the request result data returned by the server for the file request, and the request result data includes at least one of the following: a differential file and a target template file of the target file, wherein the differential file is obtained by processing the server, and the target file is a file in the server corresponding to the path information;

[0326] The file updating unit 1003 is used to update the target cache file according to the request result data.

[0327] As an embodiment of the present application, the cache update device can implement the following Figure 1-Figure 8 The illustrated embodiments and other related method embodiments.

[0328] The process of each module in the cache update device provided in the embodiment of the present application realizing its own function can be specifically referred to the aforementioned Figure 1-Figure 8 The description of the illustrated embodiment and other related method embodiments will not be repeated here.

[0329] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0330] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0331] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0332] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0333] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0334] In addition, in the description of the present specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish descriptions, and cannot be interpreted as indicating or suggesting relative importance. It should also be understood that although the terms "first", "second", etc. are used to describe various elements in some embodiments of the present application in the text, these elements should not be limited by these terms. These terms are only used to distinguish an element from another element. For example, the first state code can be named as the second state code, and similarly, the second state code can be named as the first state code, without departing from the scope of the various described embodiments. The first state code and the second state code are both state codes, but they are not the same state code.

[0335] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0336] Fig.11 1 is a schematic diagram of the structure of a server provided in an embodiment of the present application. The server includes at least one processor 111, a communication bus 112, a memory 113 and at least one communication interface 114.

[0337] The processor 111 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.

[0338] The communication bus 112 may include a pathway for transmitting information between the above-mentioned components.

[0339] The communication interface 114 uses any transceiver or other device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.

[0340] The memory 113 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM) or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may exist independently and be connected to the processor through a bus. The memory may also be integrated with the processor.

[0341] The memory 113 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 111. The processor 111 is used to execute the application code stored in the memory 113, thereby realizing the cache update method in the above embodiment.

[0342] As an embodiment, the processor 111 may include one or more CPUs, such as CPU 0 and CPU 1.

[0343] As an example, the server may include multiple processors, such as Fig.11 Two processors 111 in. Each processor can be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor.

[0344] As an embodiment, the server may further include an output device 115 and an input device 116. The output device 115 communicates with the processor 111 and may display information in a variety of ways. For example, the output device 115 may be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector.

[0345] The input device 116 communicates with the processor 111 and can accept user input in a variety of ways. For example, the input device 116 can be a mouse, a keyboard, a touch screen, or a sensor device.

[0346] The server can be a general-purpose server or a dedicated server. The server can be a desktop computer, a network server, an embedded device, or a server with Fig.11 The embodiment of the present application does not limit the type of server.

[0347] It is to be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the server. In other embodiments of the present application, the server may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0348] Fig.12 Schematic diagram of the structure of a terminal device provided by an embodiment of the present application. Fig.12 As shown, the terminal device of this embodiment includes: at least one processor 13 ( Fig.12 Only one is shown in the figure), a memory 11, and a communication interface 14. The memory 11 stores a computer program 12 that can be run on a processor 13. When the processor 13 executes the computer program 12, the steps in the above-mentioned cache update method embodiments are implemented. Alternatively, when the processor 13 executes the computer program 12, the functions of each module / unit in the above-mentioned device embodiments are implemented, such as Fig.10 Functions of units 1001 to 1003 are shown.

[0349] The terminal device may be a computing device such as a desktop computer, a notebook, a PDA, or a server. The terminal device may include, but is not limited to, a processor 13 and a memory 11. Those skilled in the art will appreciate that Fig.12It is only an example of a terminal device and does not constitute a limitation of the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include an input and sending device, a network access device, a bus, etc.

[0350] The communication interface 14 uses any transceiver-like device to communicate with other devices or communication networks, such as 5G network, WLAN network, etc.

[0351] The processor 13 may be a CPU, or other general-purpose processors, digital signal processors (DSP), ASICs, field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0352] In some embodiments, the memory 11 may be an internal storage unit of the terminal device, such as a hard disk or memory of the terminal device. The memory 11 may also be an external storage device of the terminal device, such as a plug-in hard disk equipped on the terminal device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Further, the memory 11 may also include both an internal storage unit of the terminal device and an external storage device. The memory 11 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as program codes of a computer program, etc. The memory 11 may also be used to temporarily store data that has been sent or is to be sent.

[0353] The following uses a mobile phone as an example. Fig.13 A schematic structural diagram of the mobile phone 100 is shown.

[0354] The mobile phone 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a SIM card interface 195, etc. The sensor module 180 may include a gyroscope sensor 180A, an acceleration sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an ambient light sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, and a touch sensor 180K (of course, the mobile phone 100 may also include other sensors, such as a temperature sensor, a pressure sensor, an air pressure sensor, a bone conduction sensor, etc., which are not shown in the figure).

[0355] The processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural network processor (Neural-network Processing Unit, NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors. Among them, the controller can be the nerve center and command center of the mobile phone 100. The controller can generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions.

[0356] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0357] The processor 110 may run the cache update method provided in the embodiment of the present application. The processor 110 may include different devices. For example, when a CPU and a GPU are integrated, the CPU and the GPU may cooperate to execute the cache update method provided in the embodiment of the present application. For example, part of the algorithm in the cache update method is executed by the CPU, and another part of the algorithm is executed by the GPU to obtain faster processing efficiency.

[0358] It should be understood that in actual applications, the mobile phone 100 may include Fig.13 The embodiments of the present application are not limited to the more or fewer components shown. The illustrated mobile phone 100 is only an example, and the mobile phone 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations. The various components shown in the figure may be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0359] In addition, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.

[0360] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0361] An embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0362] An embodiment of the present application also provides a chip system, which includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the steps in the above-mentioned method embodiments.

[0363] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. Computer-readable storage media may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, ROM, random access memory (Random Access Memory, RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0364] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0365] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0366] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0367] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A cache update method, characterized in that: Applied to a server, the method comprises: The server receives a file request sent by a terminal device, wherein the file request includes path information and a cache file identifier; Acquire the target file according to the path information; Sending a request result for responding to the file request to the terminal device, the request result including a status code, and the status code is a status code of a transmission protocol; In the case that the target file does not match the cache file identifier, the status code is a third status code and the request result also includes a differential file; wherein the third status code is used to instruct the terminal device to update the target cache file based on the differential file; the differential file is a file used to describe the difference between the target file and the historical cache file, the historical cache file is a file in the server cache, and the historical cache file and the target cache file correspond to the cache file identifier.

2. The cache update method according to claim 1, characterized in that: In the case where the target file matches the cache file identifier, the status code in the request result is a second status code, wherein the second status code is used to indicate that there is no need to update the target cache file.

3. The cache update method according to claim 1, characterized in that: After sending the request result for responding to the file request to the terminal device, the method further includes: In a case where the request result also includes a differential file, the historical cache file is updated to be the target file.

4. The cache update method according to claim 1, characterized in that: The file request also includes differential information for indicating that the terminal device supports the differential update mode. Before sending the request result for responding to the file request to the terminal device, the method also includes: Determining whether the terminal device supports a differential update mode; In the case where the target file does not match the cache file identifier, the status code is a third status code and the request result also includes a differential file, specifically: In the case that the target file does not match the cache file identifier and the terminal device supports the differential update mode, the status code in the request result is the third status code and the request result also includes the differential file.

5. The cache update method according to claim 4, characterized in that: The method further comprises: When the target file does not match the cache file identifier and the terminal device does not support differential update mode, the status code in the request result is a first status code and the request result also includes the target file, wherein the first status code is used to instruct the terminal device to replace and update the target cache file based on the target file.

6. The cache update method according to claim 4, characterized in that: The difference information includes an algorithm identifier of a file difference algorithm supported by the terminal device.

7. The cache update method according to any one of claims 1 to 6, characterized in that: The request result also includes at least one of the following: a file identifier and a target algorithm identifier of the target file, wherein the target algorithm identifier is used to indicate the file difference algorithm used by the server to obtain the difference file.

8. The cache update method according to any one of claims 1 to 7, characterized in that: Before the server receives the file request sent by the terminal device, the method further includes: In the case that the target file has a target template file, the target template file is stored in the server cache as a historical cache file of the target file.

9. The cache update method according to any one of claims 4 to 8, characterized in that: Before sending the request result for responding to the file request to the terminal device, the method further includes: Determining whether the terminal device stores a target template file; In the case where the target file does not match the cache file identifier and the terminal device supports the differential update mode, the status code in the request result is the third status code and the request result also includes the differential file, specifically: When the target file does not match the cache file identifier and the terminal device supports differential update mode and the target file has a target template file and the terminal device stores the target template file, the status code in the request result is the third status code and the request result also includes the differential file.

10. The cache update method according to claim 9, characterized in that: The method further comprises: In the case where the target file does not match the cache file identifier and the terminal device supports differential update mode and the target file has a target template file and the terminal device does not store the target template file, the status code in the request result is a fourth status code and the request result also includes the target template file and the differential file; The fourth status code is used to instruct the terminal device to update the target cache file based on the differential file and the target template file.

11. A cache update method, characterized in that: Applied to a terminal device, the method comprises: The terminal device sends a file request to the server, wherein the file request includes path information and a cache file identifier, wherein the cache file identifier is a file identifier of a target cache file cached in the terminal device; receiving a request result returned by the server for the file request, wherein the request result includes a status code; When the status code is the third status code and the request result also includes a differential file, the target cache file is updated according to the differential file, and the third status code is used to instruct the terminal device to update the target cache file based on the differential file; the differential file is a file used to describe the difference between the target file and the historical cache file, and the historical cache file and the target cache file correspond to the cache file identifier.

12. The cache update method according to claim 11, characterized in that: When the status code is the second status code, the target cache file is not updated.

13. The cache update method according to claim 11, characterized in that: When the status code is the third status code and the request result also includes a differential file, updating the target cache file according to the differential file is specifically as follows: When the status code is the third status code and the request result further includes a differential file and the terminal device supports a differential update mode, the target cache file is updated according to the differential file.

14. The cache update method according to claim 11, characterized in that: When the status code is the first status code and the request result includes a target file, the target cache file is updated according to the target file.

15. The cache update method according to any one of claims 11 to 14, characterized in that: When the status code is the fourth status code and the request result includes the target template file and the differential file, the target cache file is updated based on the differential file and the target template file.

16. A cache update method, characterized in that: Applied to a system including a server and a terminal device, the method includes: The terminal device sends a file request to the server, wherein the file request includes path information and a cache file identifier, wherein the cache file identifier is a file identifier of a target cache file cached in the terminal device; The server receives the file request sent by the terminal device, and obtains the target file according to the path information; sends a request result for responding to the file request to the terminal device, wherein the request result includes a status code, and the status code is a status code of the transmission protocol; The terminal device receives the request result returned by the server for the file request, and when the status code is a third status code and the request result also includes a differential file, updates the target cache file according to the differential file, and the third status code is used to instruct the terminal device to update the target cache file based on the differential file; the differential file is a file used to describe the difference between the target file and the historical cache file, and the historical cache file and the target cache file correspond to the cache file identifier.

17. A server, characterized in that: The server includes a memory, a processor and a communication interface. The memory stores a computer program that can be run on the processor. When the processor executes the computer program, the cache update method according to any one of claims 1 to 10 is implemented.

18. A terminal device, characterized in that: The terminal device includes a memory, a processor and a communication interface, the memory stores a computer program that can be run on the processor, and the processor implements the cache update method according to any one of claims 11 to 15 when executing the computer program.

19. A system, characterized in that: The system includes a server and a terminal device, wherein the server is used to execute the cache update method according to any one of claims 1 to 10, and the terminal device is used to execute the cache update method according to any one of claims 11 to 15.