Method for processing cache data and related products

By using the dependency tree to generate configuration files in the browser to determine the latest file, and update cache files through content distribution network, the page loading performance problems caused by file update failure in the existing technology are solved, and faster page loading speed and lower traffic costs are achieved.

CN112667937BActive Publication Date: 2025-04-18CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011609642.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-29
Publication Date
2025-04-18
Estimated Expiration
2040-12-29

AI Technical Summary

Technical Problem

When existing web browsers process cached files, if the file name is not changed or the timestamp is not appended, the file contents of the next updated fail, affecting the page loading performance.

Method used

By obtaining file requests from the client, obtaining files in the local resource, and generating the configuration file corresponding to the file based on the pre-built dependency tree. Determine whether the file is the latest version. If not, obtain the latest file through the content distribution network, send and save the latest file to the client, and delete the old file.

Benefits of technology

It effectively improves the speed of page loading files, avoids read failures and functional problems caused by unupdated files, and saves traffic costs on the content distribution network.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112667937B_ABST
    Figure CN112667937B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a method for processing cache data and related products thereof, the method comprising: obtaining a first file in a local resource; generating a first configuration file corresponding to the first file according to a pre-built dependency tree; judging whether there is a second file with the same file name as the first file in the project file set according to the first configuration file; if the second file exists in the project file set, judging whether the first number of the first file is the same as the second number of the second file; if the first number is not the same as the second number, obtaining the second file through a content distribution network, sending the second file to the client, saving the second file in the local resource, and deleting the first file. The embodiment of the present application judges whether the first file is the latest file according to the first configuration file, and if not, obtains and saves the second file, and does not need to go to the CDN to pull the project files of the entire project, thereby saving the traffic cost of the content distribution network CDN and improving the page loading speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method for processing cache data and related products thereof. Background Art

[0002] Currently, in existing web browsers, the purpose of caching file contents is mainly achieved by relying on the browser cache and parameters such as cache-control and expire to control the expiration time of files. However, if the file name is not changed or the timestamp is not appended, the browser will not be able to obtain the latest content of the file when it is updated next time, resulting in file reading failure or functional problems, affecting page loading performance. Summary of the invention

[0003] The main purpose of the embodiments of the present application is to provide a method for processing cache data and related products, which can effectively further improve the speed of page loading files.

[0004] In a first aspect, an embodiment of the present application provides a method for processing cache data, which is applied to an electronic device, and is characterized in that the method includes:

[0005] Obtaining a file request from a client, where the file request is used to obtain a first file;

[0006] Obtain the first file in the local resource;

[0007] Generate a first configuration file corresponding to the first file according to a pre-built dependency tree, wherein the pre-built dependency tree is used to store project file information in a project file set;

[0008] Determining whether a second file exists in the project file set according to the first configuration file, wherein the file name of the second file is the same as the file name of the first file;

[0009] If the second file exists in the project file set, determining whether the first number of the first file is the same as the second number of the second file;

[0010] If the first number is different from the second number, the second file is obtained through a content distribution network, the second file is sent to the client, the second file is saved in a local resource, and the first file is deleted.

[0011] Optionally, if the second file exists in the project file set, before determining whether the first number of the first file is the same as the second number of the second file, the method further includes: traversing the project files in the project file set through the dependency tree, extracting the second number of the second file in the node of the dependency tree corresponding to the second file; and determining the first number of the first file according to the first configuration file of the first file.

[0012] Optionally, if the second file exists in the project file set, after determining whether the first number of the first file is the same as the second number of the second file, the method further includes:

[0013] If the first number of the first file is the same as the second number of the second file, the file content of the first file is returned; and the first file is saved.

[0014] Optionally, the method further includes: traversing the files in the project file set through an algorithm to generate the dependency tree, and marking the nodes corresponding to each file in the project file set, wherein the nodes corresponding to each file include the following information: the name of the file, the number of the file, the file type, and information on whether there are child nodes.

[0015] Optionally, after determining whether the second file exists in the project file set according to the first configuration file, the method further includes: if the second file does not exist in the project file set, acquiring the first file through the content distribution network and saving the first file.

[0016] Optionally, if the first number is different from the second number, obtaining the second file through a content distribution network, sending the second file to the client, saving the second file, and deleting the first file, includes: if the first number of the first file is different from the second number of the second file, obtaining the actual Internet Protocol address (IP) address of the domain name through a domain name system (DNS) resolution based on the domain name to be accessed provided by the browser through the content distribution network; submitting an access request to the actual IP address through the content distribution network; obtaining the second file from the actual IP address through the content distribution network, sending the second file to the client, saving the second file in a local resource, and deleting the first file.

[0017] In a second aspect, an embodiment of the present application provides a device for processing cache data, characterized in that the device includes:

[0018] an acquiring unit, configured to acquire a file request from a client, wherein the file request is used to acquire a first file; and to acquire the first file;

[0019] A generating unit, configured to generate a first configuration file corresponding to the first file according to a pre-built dependency tree, wherein the pre-built dependency tree is used to store project file information in a project file set;

[0020] A first judging unit, configured to judge whether a second file exists in the project file set according to the first configuration file, wherein the file name of the second file is the same as the file name of the first file;

[0021] a second judging unit, configured to judge whether a first number of the first file is the same as a second number of the second file if the second file exists in the project file set;

[0022] A sending unit is used to obtain the second file through a content distribution network if the first number is different from the second number, send the second file to the client, save the second file in a local resource, and delete the first file.

[0023] Optionally, if the second file exists in the project file set, before determining whether the first number of the first file is the same as the second number of the second file, the cache data processing device is also used to: traverse the project files in the project file set through the dependency tree, and extract the second number of the second file in the node of the dependency tree corresponding to the second file; determine the first number of the first file according to the first configuration file of the first file.

[0024] Optionally, if the second file exists in the project file set, after determining whether the first number of the first file is the same as the second number of the second file, the cache data processing device is also used to: return the file content of the first file if the first number of the first file is the same as the second number of the second file; and save the first file.

[0025] Optionally, the cache data processing device is also used to: traverse the files in the project file set through an algorithm, generate the dependency tree, and mark the nodes corresponding to each file in the project file set, wherein the nodes corresponding to each file include the following information: file name, file number, file type and information on whether there are child nodes.

[0026] Optionally, after determining whether the second file exists in the project file set according to the first configuration file, the cache data processing device is further used to: if the second file does not exist in the project file set, obtain the first file through the content distribution network and save the first file.

[0027] Optionally, if the first number is different from the second number, the second file is obtained through a content distribution network, the second file is sent to the client, the second file is saved, and the first file is deleted. The sending unit is specifically used to: if the first number of the first file is different from the second number of the second file, the actual Internet Protocol address IP address of the domain name is obtained through the content distribution network according to the domain name to be accessed provided by the browser through the domain name system DNS resolution; submit an access request to the actual IP address through the content distribution network; obtain the second file from the actual IP address through the content distribution network, send the second file to the client, save the second file in the local resource, and delete the first file.

[0028] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps of any method in the first aspect of the embodiment of the present application.

[0029] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps described in any method of the first aspect of the embodiment of the present application.

[0030] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in any method of the first aspect of the embodiment of the present application. The computer program product may be a software installation package.

[0031] It can be seen that the embodiment of the present application obtains a file request from the client, obtains the first file in the local resource; generates a first configuration file corresponding to the first file according to a pre-built dependency tree; determines whether there is a second file with the same file name as the first file in the project file set according to the first configuration file; if the second file exists in the project file set, determines whether the first number of the first file is the same as the second number of the second file, and the file number is the file number generated according to the project file submission record in the project file set; if the first number is not the same as the second number, obtains the second file through the content distribution network, sends the second file to the client, saves the second file in the local resource, and deletes the first file. The embodiment of the present application generates a first configuration file corresponding to the first file through a dependency tree, determines whether the first file is the latest file according to the first configuration file, and obtains and saves the second file if it is not, and there is no need to go to the CDN to pull the project files of the entire project, saving the content distribution network CDN traffic cost and improving the page loading speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0033] Figure 1 A flowchart of a method for processing cache data provided in an embodiment of the present application;

[0034] Figure 2 A schematic diagram of a node structure of a dependency tree provided in an embodiment of the present application;

[0035] Figure 3 A flowchart of a method for processing cache data provided in an embodiment of the present application;

[0036] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;

[0037] Figure 5 It is a block diagram of the functional units of a device for processing cache data provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0039] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0040] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0041] The following is a detailed description of the embodiments of the present application.

[0042] In order to effectively further improve the speed of page loading files, the present application provides a method for processing cache data, which is applied to electronic devices, specifically, Figure 1 As shown, Figure 1 A flowchart of a method for processing cache data provided in an embodiment of the present application, the method may include but is not limited to the following steps:

[0043] S101, the electronic device obtains a file request from a client;

[0044] The file request is used to obtain a first file, and the first file may be a file required on the web page of the application APP.

[0045] S102, the electronic device obtains a first file in a local resource;

[0046] In a specific implementation, the electronic device obtains the first file in the local resource, including but not limited to: after the electronic device obtains the file request from the client, the electronic device intercepts the first file in the local resource through a link.

[0047] S103, the electronic device generates a first configuration file corresponding to the first file according to the pre-built dependency tree;

[0048] The pre-built dependency tree is used to store project file information in the project file set.

[0049] A node in the dependency tree includes the name of a project file in the project file set, the number of the project file, the type of the project file, and information about whether the project file has child nodes. A node in the dependency tree may also include the size of the project file.

[0050] The project file number can be generated by the electronic device through the open source distributed version control system (git) submission record of the calculated file to generate a unique identity document (ID) corresponding to the project file, or can be generated by the electronic device through the open source git submission time of the calculated file to generate a unique ID corresponding to the project file, or can be encoded in other ways to generate the ID corresponding to the project file. Each project file in the project file set corresponds to a project file number.

[0051] The project file type includes: folder, file, wherein the folder can be marked with a first value, and the file can be marked with a second value. The first value is different from the second value. For example, the folder is marked with 1, and the file is marked with 0. When the project file is a folder, the project file type is 1.

[0052] The information about whether the project file has child nodes includes but is not limited to: the project file has no child nodes, and the project file has one or more child nodes.

[0053] The project files in the project file set may be files stored in the same database or files stored in different databases.

[0054] The first configuration file is a manifest file corresponding to the first file.

[0055] In a specific implementation, the electronic device generates a first configuration file corresponding to the first file according to a pre-built dependency tree, including but not limited to: when the APP is started, the electronic device generates a first configuration file manifest file corresponding to the first file according to the pre-built dependency tree.

[0056] In one possible example, the electronic device also traverses the files in the project file set through an algorithm, generates a dependency tree, and marks the nodes corresponding to each file in the project file set, wherein the nodes corresponding to each file include the following information: the name of the file, the number of the file, the file type, and whether there are child nodes.

[0057] Among them, the project files in the project file set are the latest updated files. For example, when the latest project files are updated in the server, the project files in the project file set are the latest project files in the server. When the latest project files are saved in the local resources, the project files in the project file set are the latest project files saved in the local resources.

[0058] In a specific implementation, the electronic device also traverses the files in the project file set through an algorithm, generates a dependency tree, and marks the nodes corresponding to each file in the project file set, including but not limited to: the electronic device traverses the files in the project file set through a recursive algorithm, generates a dependency tree, and marks the nodes corresponding to each file in the project file set.

[0059] In a specific implementation, the electronic device also traverses the files in the project file set through an algorithm, generates a dependency tree, and marks the nodes corresponding to each file in the project file set, including but not limited to: the electronic device traverses the files in the project file set through a Node script algorithm, generates a dependency tree, and marks the nodes corresponding to each file in the project file set.

[0060] It needs further explanation that the node corresponding to the project file in the project file set in the dependency tree can have one or more child nodes, that is, the project file can have one or more child files; or the node corresponding to the project file in the project file set in the dependency tree has no child nodes. Figure 2 , Figure 2 A schematic diagram of a node structure of a dependency tree provided in an embodiment of the present application, wherein each node includes information about a file name, a file number, a file type, and whether there are child nodes. For example, if a project file corresponding to a node in a dependency tree has two child files, then the node has two child nodes.

[0061] S104, the electronic device determines whether a second file exists in the project file set according to the first configuration file;

[0062] The file name of the second file is the same as the file name of the first file.

[0063] In a specific implementation, the electronic device determines whether the second file exists in the project file set according to the first configuration file, including: the electronic device determines whether the second file with the same file name as the first file exists in the project file set according to the manifest file corresponding to the first file.

[0064] S105: If the second file exists in the project file set, the electronic device determines whether the first number of the first file is the same as the second number of the second file;

[0065] In a possible instance, if there is a second file in the project file set, before the electronic device determines whether the first number of the first file is the same as the second number of the second file, it also includes: the electronic device traverses the project files in the project file set through the dependency tree, and extracts the second number of the second file in the node of the dependency tree corresponding to the second file; the electronic device determines the first number of the first file based on the first configuration file of the first file.

[0066] In a specific implementation, the electronic device determines the first number of the first file according to the first configuration file of the first file, including but not limited to: the electronic device determines the first number of the first file according to manifest.json in the manifest file of the first file.

[0067] In a possible instance, if there is a second file in the project file set, then after the electronic device determines whether the first number of the first file is the same as the second number of the second file, it also includes: if the first number of the first file is the same as the second number of the second file, the electronic device returns the file content of the first file; and saves the first file in the local resource.

[0068] In a specific implementation, if the first number of the first file is the same as the second number of the second file, the electronic device returns the file content of the first file, including but not limited to: if the first number of the first file is the same as the second number of the second file, the electronic device returns the file content of the first file to the client.

[0069] S106: If the first number is different from the second number, the electronic device obtains the second file through the content distribution network, sends the second file to the client, saves the second file in the local resource, and deletes the first file.

[0070] In a possible example, if the first number of the first file is different from the second number of the second file, the actual Internet Protocol address (IP) address of the domain name is obtained through the domain name system (DNS) resolution based on the domain name to be accessed provided by the browser through the content distribution network; an access request is submitted to the actual IP address through the content distribution network; the second file is obtained from the actual IP address through the content distribution network, the second file is sent to the client, the second file is saved in the local resource, and the first file is deleted.

[0071] In a possible example, if the first number is different from the second number, the second file is obtained through the content distribution network, the second file is sent to the client, the second file is saved in the local resource, and after deleting the first file, the electronic device saves the second file in the cache.

[0072] It can be seen that the embodiment of the present application obtains a file request from a client, obtains a first file in a local resource; generates a first configuration file corresponding to the first file according to a pre-built dependency tree; determines whether a second file exists in the project file set according to the first configuration file, and the file name of the second file is the same as the file name of the first file; if the second file exists in the project file set, determines whether the first number of the first file is the same as the second number of the second file, and the file number is a file number generated according to the project file submission record in the project file set; if the first number is different from the second number, obtains the second file through a content distribution network, sends the second file to the client, saves the second file in the local resource, and deletes the first file.

[0073] The following is a detailed description of the embodiments of the present application through a specific example.

[0074] With the above Figure 1 The embodiment shown is consistent with that shown in FIG. Figure 3 , Figure 3 1 is a flow chart of a method for processing cache data provided by an embodiment of the present application, which is applied to an electronic device. The method includes:

[0075] S301, the electronic device obtains a file request from a client;

[0076] The file request is used to obtain the first file.

[0077] S302, the electronic device obtains a first file in a local resource;

[0078] S303: The electronic device generates a first configuration file corresponding to the first file according to a pre-built dependency tree; wherein the pre-built dependency tree is used to store project file information in a project file set.

[0079] S304, the electronic device determines whether there is a second file with the same file name as the first file in the project file set according to the first configuration file;

[0080] S305: If the electronic device has a second file in the project file set, determining whether the first number of the first file is the same as the second number of the second file;

[0081] S306: If the first number of the first file is different from the second number of the second file, the electronic device obtains the actual Internet Protocol address IP address of the domain name through the domain name system DNS resolution according to the domain name to be accessed provided by the browser through the content distribution network;

[0082] S307, the electronic device submits an access request to the actual IP address through the content distribution network;

[0083] S308: The electronic device obtains a second file from the actual IP address through the content distribution network, sends the second file to the client, saves the second file in the local resource, and deletes the first file.

[0084] It can be seen that the embodiment of the present application obtains a file request from the client; obtains the first file in the local resource; generates the first configuration file corresponding to the first file according to the pre-built dependency tree; determines whether there is a second file with the same file name as the first file in the project file set according to the first configuration file; if there is a second file in the project file set, determines whether the first number of the first file is the same as the second number of the second file; if the first number of the first file is not the same as the second number of the second file, the electronic device obtains the actual Internet Protocol address IP address of the domain name through the domain name system DNS resolution based on the domain name to be accessed provided by the browser through the content distribution network; submits an access request to the actual IP address through the content distribution network; obtains the second file from the actual IP address through the content distribution network, sends the second file to the client, saves the second file in the local resource, and deletes the first file. The embodiment of the present application generates the first configuration file corresponding to the first file through the dependency tree, determines whether the first file is the latest file according to the first configuration file, and obtains and saves the second file if it is not, and does not need to go to the CDN to pull the project files of the entire project, saving the content distribution network CDN traffic cost and improving the page loading speed.

[0085] See also Figure 4 , Figure 4 4 is a structural diagram of an electronic device 400 provided in an embodiment of the present application. As shown in the figure, the electronic device 400 includes an application processor 410, a memory 420, a communication interface 430, and one or more programs 421, wherein the one or more programs 421 are stored in the above-mentioned memory 420 and are configured to be executed by the above-mentioned application processor 410, and the one or more programs 421 include for performing the following steps:

[0086] A method for processing cache data, applied to an electronic device, is characterized in that the method comprises:

[0087] Obtaining a file request from a client, where the file request is used to obtain a first file;

[0088] Obtain the first file in the local resource;

[0089] Generate a first configuration file corresponding to the first file according to a pre-built dependency tree, wherein the pre-built dependency tree is used to store project file information in a project file set;

[0090] Determining whether a second file exists in the project file set according to the first configuration file, wherein the file name of the second file is the same as the file name of the first file;

[0091] If the second file exists in the project file set, determining whether the first number of the first file is the same as the second number of the second file;

[0092] If the first number is different from the second number, the second file is obtained through a content distribution network, the second file is sent to the client, the second file is saved in a local resource, and the first file is deleted.

[0093] It can be seen that the embodiment of the present application obtains a file request from the client, obtains the first file in the local resource; generates a first configuration file corresponding to the first file according to a pre-built dependency tree, and the pre-built dependency tree is used to store project file information in the project file set; determines whether there is a second file in the project file set according to the first configuration file, and the file name of the second file is the same as the file name of the first file; if the second file exists in the project file set, determines whether the first number of the first file is the same as the second number of the second file, and the file number is the file number generated according to the project file submission record in the project file set; if the first number is not the same as the second number, obtain the second file through the content distribution network, send the second file to the client, save the second file in the local resource, and delete the first file. The embodiment of the present application generates a first configuration file corresponding to the first file through a dependency tree, determines whether the first file is the latest file according to the first configuration file, and obtains and saves the second file if it is not, and there is no need to go to the CDN to pull the project files of the entire project, saving the content distribution network CDN traffic cost and improving the page loading speed.

[0094] In a possible example, if the second file exists in the project file set, before determining whether the first number of the first file is the same as the second number of the second file, the one or more programs 421 also include executing the following steps: traversing the project files in the project file set through the dependency tree, extracting the second number of the second file in the node of the dependency tree corresponding to the second file; determining the first number of the first file according to the first configuration file of the first file.

[0095] In a possible example, if the second file exists in the project file set, after determining whether the first number of the first file is the same as the second number of the second file, the one or more programs 421 also include executing the following steps: if the first number of the first file is the same as the second number of the second file, returning the file content of the first file; and saving the first file.

[0096] In a possible example, the one or more programs 421 also include a program for performing the following steps: traversing the files in the project file set through an algorithm, generating the dependency tree, marking the nodes corresponding to each file in the project file set, wherein the nodes corresponding to each file include the following information: the name of the file, the number of the file, the file type, and information on whether there are child nodes.

[0097] In a possible example, after determining whether the second file exists in the project file set according to the first configuration file, the one or more programs 421 also include executing the following steps: if the second file does not exist in the project file set, obtaining the first file through the content distribution network and saving the first file.

[0098] In a possible example, if the first number is different from the second number, the second file is obtained through a content distribution network, the second file is sent to the client, the second file is saved, and the first file is deleted. The one or more programs 421 include the following steps: if the first number of the first file is different from the second number of the second file, the actual Internet Protocol address (IP address) of the domain name is obtained through the content distribution network according to the domain name to be accessed provided by the browser through the domain name system (DNS) resolution; an access request is submitted to the actual IP address through the content distribution network; the second file is obtained from the actual IP address through the content distribution network, the second file is sent to the client, the second file is saved in the local resource, and the first file is deleted.

[0099] The above mainly introduces the scheme of the embodiment of the present application from the perspective of the execution process on the method side. It is understandable that, in order to realize the above functions, the electronic device includes a hardware structure and / or software module corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the units and algorithm steps of each example described in the embodiments provided herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware 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 the present application.

[0100] The embodiment of the present application can divide the electronic device into functional units according to the above method example. For example, each functional unit can be divided according to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0101] Figure 5 1 is a block diagram of the functional units of the device for processing cache data 500 involved in the embodiment of the present application. The device for processing cache data 500 includes:

[0102] The acquisition unit 501 is used to acquire a file request from a client, wherein the file request is used to acquire a first file; and to acquire the first file;

[0103] A generating unit 502, configured to generate a first configuration file corresponding to the first file according to a pre-built dependency tree, wherein the pre-built dependency tree is used to store project file information in a project file set;

[0104] A first determining unit 503 is configured to determine whether a second file exists in the project file set according to the first configuration file, and the file name of the second file is the same as the file name of the first file;

[0105] A second judging unit 504 is configured to judge whether the first number of the first file is the same as the second number of the second file if the second file exists in the project file set;

[0106] The sending unit 505 is configured to obtain the second file through a content distribution network, send the second file to a client, save the second file in a local resource, and delete the first file if the first number is different from the second number.

[0107] The data processing device 500 may further include a storage unit 506 for storing program codes and data of the electronic device. The storage unit 506 may be a memory.

[0108] It can be seen that the embodiment of the present application obtains a file request from a client, obtains a first file in a local resource; generates a first configuration file corresponding to the first file according to a pre-built dependency tree, and the pre-built dependency tree is used to store project file information in a project file set; determines whether there is a second file with the same file name as the first file in the project file set according to the first configuration file; if there is a second file in the project file set, determines whether the first number of the first file is the same as the second number of the second file, and the file number is a file number generated according to the project file submission record in the project file set; if the first number is not the same as the second number, obtains the second file through a content distribution network, sends the second file to the client, saves the second file in a local resource, and deletes the first file. The embodiment of the present application generates a first configuration file corresponding to the first file through a dependency tree, determines whether the first file is the latest file according to the first configuration file, and obtains and saves the second file if it is not, and does not need to go to the CDN to pull the project files of the entire project, saving the traffic cost of the content distribution network CDN and improving the page loading speed.

[0109] In a possible example, if the second file exists in the project file set, before determining whether the first number of the first file is the same as the second number of the second file, the cache data processing device 500 is further used to: traverse the project files in the project file set through the dependency tree, extract the second number of the second file in the node of the dependency tree corresponding to the second file; and determine the first number of the first file according to the first configuration file of the first file.

[0110] In a possible example, if the second file exists in the project file set, after determining whether the first number of the first file is the same as the second number of the second file, the cache data processing device 500 is also used to: return the file content of the first file if the first number of the first file is the same as the second number of the second file; and save the first file.

[0111] In a possible example, the cache data processing device 500 is also used to: traverse the files in the project file set through an algorithm, generate the dependency tree, and mark the nodes corresponding to each file in the project file set, wherein the nodes corresponding to each file include the following information: the name of the file, the number of the file, the file type, and whether there are child nodes.

[0112] In a possible example, after determining whether the second file exists in the project file set according to the first configuration file, the cache data processing device 500 is further used to: if the second file does not exist in the project file set, obtain the first file through the content distribution network and save the first file.

[0113] In a possible example, if the first number is different from the second number, the second file is obtained through a content distribution network, the second file is sent to the client, the second file is saved, and the first file is deleted. The sending unit 505 is specifically used for: if the first number of the first file is different from the second number of the second file, the actual Internet Protocol address IP address of the domain name is obtained through the content distribution network according to the domain name to be accessed provided by the browser through the domain name system DNS resolution; submitting an access request to the actual IP address through the content distribution network; obtaining the second file from the actual IP address through the content distribution network, sending the second file to the client, saving the second file in the local resource, and deleting the first file.

[0114] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.

[0115] The present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.

[0116] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

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

[0118] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the above-mentioned units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.

[0119] The units described above 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.

[0120] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0121] If the above-mentioned integrated 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 memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the above-mentioned methods of each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.

[0122] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.

[0123] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application. At the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for processing cache data, applied to an electronic device, characterized in that: The method comprises: Obtaining a file request from a client, wherein the file request is used to obtain a first file, wherein the first file is a file content of a browser; Obtain the first file in the local resource; Traversing the files in the project file set by an algorithm to generate a dependency tree, marking the nodes corresponding to each file in the project file set, wherein the nodes corresponding to each file include the following information: the name of the file, the number of the file, the file type, and whether there are child nodes, including: traversing the files in the project file set by a Node script algorithm to generate the dependency tree, marking the nodes corresponding to each file in the project file set, and the project files in the project file set are the latest project files saved in the local resources; Generate a first configuration file corresponding to the first file according to the dependency tree, the dependency tree is used to store project file information in a project file set, and the first configuration file is a manifest file corresponding to the first file; Determining whether a second file exists in the project file set according to the first configuration file, wherein the file name of the second file is the same as the file name of the first file; Traversing the project files in the project file set through the dependency tree, and extracting the second number of the second file in the node of the dependency tree corresponding to the second file; Determining the first number of the first file according to the first configuration file of the first file includes: determining the first number of the first file according to manifest.json in the manifest file of the first file; If the second file exists in the project file set, determining whether the first number of the first file is the same as the second number of the second file; If the first number of the first file is the same as the second number of the second file, returning the file content of the first file; and saving the first file; If the first number is different from the second number, obtaining the second file through a content distribution network, sending the second file to the client, saving the second file in a local resource, and deleting the first file; If the first number is different from the second number, the second file is obtained through a content distribution network, the second file is sent to a client, the second file is saved in a local resource, and the first file is deleted, including: if the first number of the first file is different from the second number of the second file, the actual Internet Protocol address (IP) address of the domain name is obtained through the content distribution network according to the domain name to be accessed provided by the browser through a domain name system (DNS) resolution; an access request is submitted to the actual IP address through the content distribution network; the second file is obtained from the actual IP address through the content distribution network, the second file is sent to the client, the second file is saved in a local resource, and the first file is deleted.

2. The method according to claim 1, characterized in that After determining whether the second file exists in the project file set according to the first configuration file, the method further includes: If the second file does not exist in the project file set, the first file is obtained through the content distribution network and the first file is saved.

3. A device for processing cache data, characterized in that: The device is used to perform the method according to any one of claims 1 or 2, and the device comprises: an acquiring unit, configured to acquire a file request from a client, wherein the file request is used to acquire a first file; and to acquire the first file; A generating unit, configured to generate a first configuration file corresponding to the first file according to a pre-built dependency tree, wherein the pre-built dependency tree is used to store project file information in a project file set; A first judging unit, configured to judge whether a second file exists in the project file set according to the first configuration file, wherein the file name of the second file is the same as the file name of the first file; a second judging unit, configured to judge whether a first number of the first file is the same as a second number of the second file if the second file exists in the project file set; A sending unit is used to obtain the second file through a content distribution network if the first number is different from the second number, send the second file to the client, save the second file in a local resource, and delete the first file.

4. The device according to claim 3, characterized in that The sending unit is further configured to obtain an actual Internet Protocol address (IP) of the domain name through a domain name system (DNS) resolution according to the domain name to be accessed provided by the browser through the content distribution network if the first number of the first file is different from the second number of the second file; and for submitting an access request to the actual IP address through a content distribution network; And it is used to obtain the second file from the actual IP address through the content distribution network, send the second file to the client, save the second file in the local resource, and delete the first file.

5. An electronic device, characterized in that: The method comprises a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in the method according to claim 1 or 2.

6. A computer-readable storage medium, characterized in that: It stores a computer program for electronic data exchange, wherein the computer program causes a computer to execute the method as claimed in claim 1 or 2.

Citation Information

Patent Citations

  • Resource file sending method and resource file caching method and device

    CN104735112A

  • Maven-based dependency management method and device, electronic device and storage medium

    CN111783103A