Method, device and system for refreshing cache resources

Receive and process resource refresh notifications through regular expressions, which solves the problem of low cache server refresh efficiency, achieves precise batch refresh of resources and load reduction, and improves the efficiency of website resource updates.

CN114598748BActive Publication Date: 2024-09-27BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202210255221.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-08
Publication Date
2024-09-27
Estimated Expiration
2041-12-08

AI Technical Summary

Technical Problem

After the cache server was introduced, the refresh efficiency of website resources was low and frequent back-to-source verification was required, resulting in increased load on the origin site and excessive network bandwidth usage.

Method used

Use regular expressions to receive resource refresh notifications, refresh cached resources, ensure that old resources cannot be used to respond when user terminals request, obtain updated resources directly from the origin site, and save the refreshed resources in the cache for subsequent direct responses.

Benefits of technology

It improves the refresh efficiency of cached resources, reduces the number of requests and network bandwidth usage of the origin site, reduces the load of the origin site, and achieves batch and accurate refresh of resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114598748B
    Figure CN114598748B
Patent Text Reader

Abstract

The present application discloses a method, device and system for refreshing cache resources. The method includes: receiving a resource refresh notification, which indicates refreshing cache resources in the form of regular expressions; in response to the resource refresh notification, operating a first resource in the cache resources of the cache device that matches the resource refresh notification, so that the cache device cannot use the first resource to respond to the resource request of the user terminal, and the first resource matches the resource requested by the resource request; when receiving the resource request of the user terminal and the first resource cannot be used to respond, obtaining a second resource that matches the resource request from the source station; and sending the second resource to the user terminal. The present application solves the technical problem of low cache refresh efficiency in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet, and in particular to a method, device and system for refreshing cache resources. Background Art

[0002] In traditional HTTP (abbreviation of Hypertext Transfer Protocol) websites, the way to refresh files is to set an expiration time for the resource file. After the file expires, the client goes to the source site to verify whether the local cache file is available. If the source site has not modified the file, the client is informed that the file has not been modified and the local cache file can be used.

[0003] With the development of the Internet, the number of users visiting websites will also increase. When the number of visits to a website reaches a certain level, the use of cache servers is introduced. The purpose of cache servers is to reduce requests to the source site. Usually, after the introduction of cache servers, files still need to be verified back to the source when they expire. For this problem, you can make full use of the advantages of cache servers, set different refresh expiration times for cache servers and clients, and notify the cache server to update resources when the source site resources are updated. In this way, while updating the client cache in a timely manner, it can also reduce requests to the source site.

[0004] For example, the expiration time of a type of resource is set to 5 minutes for the client and one day for the cache server. If there is no file update on the source site, the cache server only needs to go back to the source for verification once a day. If there is a resource update on the source site, when the resource is updated, the cache server is notified that the resource has been updated, and the client will come to the cache server every 5 minutes to verify whether the resource has been updated. In this way, the client resources can be updated in time, and the source site only needs to process requests for this type of resource when the file is updated.

[0005] Therefore, after introducing the cache server, when files are updated, in addition to updating the source site resources, the cache server needs to be notified to update the files so that the resources can be updated in time. As the business develops, the website resources become more and more, and using this file refresh method will become less efficient.

[0006] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0007] The embodiments of the present application provide a method, device and system for refreshing cache resources, so as to at least solve the technical problem of low cache refresh efficiency in the related art.

[0008] According to one aspect of an embodiment of the present application, a method for refreshing cache resources is provided, including: receiving a resource refresh notification, the resource refresh notification using a regular expression to indicate refreshing the cache resources; in response to the resource refresh notification, operating a first resource in the cache resources of the cache device that matches the resource refresh notification, so that the cache device cannot use the first resource to respond to a resource request of a user terminal, and the first resource matches the resource requested by the resource request; when a resource request from a user terminal is received and the first resource cannot be used to respond, obtaining a second resource that matches the resource request from a source station; and sending the second resource to the user terminal.

[0009] According to another aspect of an embodiment of the present application, a method for refreshing cache resources is also provided, including: receiving a resource refresh notification, the resource refresh notification using a regular expression to indicate refreshing the cache resources; in response to the resource refresh notification, deleting a first resource in the cache resources of the cache device that matches the resource refresh notification; upon receiving a resource request from a user terminal and being unable to respond using the first resource that matches the resource request, obtaining a second resource that matches the resource request from a source station; and sending the second resource to the user terminal.

[0010] According to another aspect of an embodiment of the present application, a cache resource refresh device is also provided, including: a first receiving unit, used to receive a resource refresh notification, the resource refresh notification using a regular expression to indicate that the cache resources are to be refreshed; a first processing unit, used to operate on a first resource in the cache resources of the cache device that matches the resource refresh notification in response to the resource refresh notification, so that the cache device cannot use the first resource to respond to the resource request of the user terminal, and the first resource matches the resource requested by the resource request; a first refresh unit, used to obtain a second resource that matches the resource request from the source station when a resource request from the user terminal is received and the first resource cannot be used to respond; a first sending unit, used to send the second resource to the user terminal.

[0011] According to another aspect of an embodiment of the present application, a cache resource refresh device is also provided, including: a second receiving unit, used to receive a resource refresh notification, the resource refresh notification using a regular expression to indicate that the cache resources are to be refreshed; a second processing unit, used to delete the first resource that matches the resource refresh notification in the cache resources of the cache device in response to the resource refresh notification; a second refresh unit, used to obtain a second resource that matches the resource request from a source station when a resource request from a user terminal is received and the first resource that matches the resource request cannot be used to respond; and a second sending unit, used to send the second resource to the user terminal.

[0012] According to another aspect of an embodiment of the present application, a cache resource refresh system is also provided, including: a source station, used to provide a second resource matching a resource request to a cache device; a user terminal, used to receive the second resource matching the resource request from the cache device after sending a resource request to the cache device; a cache device, used to operate a first resource in the cache resources that matches the resource refresh notification when receiving a resource refresh notification, so that the operated first resource cannot be used to respond to the resource request of the user terminal; when a resource request is received and the first resource cannot be used to respond, the second resource obtained from the source station is sent to the user terminal, the resource refresh notification uses a regular expression to indicate a refresh of the cache resources, and the first resource matches the resource requested by the resource request.

[0013] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above method is executed when the program is run.

[0014] According to another aspect of an embodiment of the present application, an electronic device is further provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above method through the computer program.

[0015] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any one of the embodiments of the above method. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0017] Figure 1 is a schematic diagram of a hardware environment of a method for refreshing cache resources according to an embodiment of the present application;

[0018] Figure 2 is a flowchart of an optional method for refreshing cache resources according to an embodiment of the present application;

[0019] Figure 3 is a flowchart of an optional method for refreshing cache resources according to an embodiment of the present application;

[0020] Figure 4 is a schematic diagram of an optional cache resource refresh solution according to an embodiment of the present application;

[0021] Figure 5 is a schematic diagram of an optional cache resource refresh device according to an embodiment of the present application;

[0022] Figure 6 is a schematic diagram of an optional cache resource refresh device according to an embodiment of the present application; and,

[0023] Figure 7 It is a structural block diagram of a terminal according to an embodiment of the present application. DETAILED DESCRIPTION

[0024] 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 should fall within the scope of protection of the present application.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0026] According to one aspect of the embodiments of the present application, a method embodiment of a method for refreshing cache resources is provided.

[0027] Optionally, in this embodiment, the above cache resource refresh method can be applied to: Figure 1 The cache resource refresh system shown in the figure includes a CDN (i.e., Content Delivery Network) source station, multiple CDN cache servers (i.e., cache devices, also called CDN nodes), and user terminals. The source station is the core of the CDN network. Each CDN cache server obtains files from the source station and caches them locally, and distributes them to the user terminal when the user terminal requests them. Figure 1As shown, the source station is connected to each CDN cache server through the network, and the user terminal can use the CDN cache server adapted by the network (generally a local CDN cache server). The above network includes but is not limited to: wide area network, metropolitan area network or local area network, and the user terminal is not limited to PC, mobile phone, tablet computer, etc.

[0028] The cache resource refresh method of the embodiment of the present application can be executed by a CDN cache server. Figure 2 is a flowchart of an optional method for refreshing cache resources according to an embodiment of the present application, such as Figure 2 As shown, the method may include the following steps:

[0029] Step S202: The CDN cache server receives a resource refresh notification, where the resource refresh notification uses a regular expression to indicate refreshing of cache resources, ie, regular refresh.

[0030] Refresh means that when the resources of the customer's origin site change, the cache of the corresponding resources on the CDN cache server needs to be deleted. When the user accesses this resource again, the updated resource will be obtained from the origin site. This operation is called refresh.

[0031] Regular refresh means that when resources with certain specified conditions on the customer's source site change in batches, one instruction can be used to describe these changed resources, that is, all resources that match the changes are described through regular expressions. In this way, customers (companies and platforms using CDN services, etc.) can refresh multiple resources with one refresh instruction. This method is called regular refresh.

[0032] The resource refresh notification is sent by the CDN refresh module. The CDN refresh module can be a separate server that is used to centrally process resource refresh notifications. During operation, it receives resource refresh notifications sent by each client side and forwards them to each CDN cache server. The CDN refresh module can be integrated on the CDN source station as an auxiliary function of the CDN source station. The CDN refresh module can also be integrated on the customer server as an auxiliary function on the customer server side, and the customer can trigger the refresh.

[0033] A regular expression is a logical formula for string operations. It can use some pre-defined specific characters and combinations of these specific characters to form one or more "regular strings". This "regular string" is used to express a filtering logic for resources.

[0034] For example, in the technical solution of the present application, the "rule string" includes at least a resource address. This address can be specific to the URL (short for Uniform Resource Locator) address of a particular resource, such as http: / / 123.com / abc / a.mv refers to the a.mv file in the abc directory; this address can also be the address of a resource collection, such as http: / / 123.com / abc refers to the abc directory (this directory may include multiple resources). Since the resource refresh notification contains a directory, the resource refresh notification can also be understood as a directory refresh notification.

[0035] The above rule string can also include attribute information, that is, the rule string at this time includes the resource address and attribute information. When matching, it is to filter out resources whose attribute information also matches from all resources that match the resource address. For example, "http: / / 123.com / abc / " & ".mv" is to find files in the ".mv" format under the abc directory. In addition to the format, the attribute information can also be cache time, resource size, resource source, etc. Through the combination of address and attribute information, flexible filtering of various resources can be achieved. For example: ("URL1" & ".mv") or ("URL2" & "time<21:0:00, November 26, 2021") means: filter out files in the ".mv" format from the address URL1, and filter out resources with a cache time earlier than 21:0:00, November 26, 2021 from the address URL2.

[0036] Step S204, in response to the resource refresh notification, the CDN cache server operates the first resource in the cache resources that matches the resource refresh notification, so that the cache device cannot use the first resource to respond to the resource request of the user terminal, and the first resource matches the resource requested by the resource request. The resource request contains information for uniquely indicating the requested resource, such as a resource identifier, a resource URL, etc., and the resource URL is used as an example for explanation below.

[0037] The purpose of the above operation is to prevent the user terminal from directly obtaining the resource from the cache device when requesting the first resource. The specific operation here can be set according to demand, such as direct deletion, setting as expired, etc.

[0038] Step S206: When receiving a resource request from a user terminal and being unable to respond using the first resource, the CDN cache server obtains a second resource matching the resource request from the source site.

[0039] When the CDN cache server receives a resource request, if the information in the resource request that uniquely represents the requested resource matches the regular expression, such as the URL in the resource request (the same as the URL of the first resource) falls within the address range represented by the regular expression, such as the resource URL "http: / / 123.com / abc / a.mv" falls within the address range "http: / / 123.com / abc / " represented by the regular expression, then it is considered that the URL in the resource request needs to be refreshed back to the source. Although the URL in the source request is the same as the URL of the first resource, since there is no first resource that can be used for direct response, the first resource will not be returned directly, but a new resource, namely the second resource, will be pulled from the CDN source station according to the URL. The second resource is also the resource that the client wants to use to replace the first resource, such as a new version of software, an updated video, etc.

[0040] Step S208: The CDN cache server sends the second resource to the user terminal.

[0041] In the above-mentioned scheme of the present application, when a resource refresh notification is received that indicates refreshing of cache resources in the form of regular expressions, an operation is performed on the first resource in the cache resources of the cache device that matches the resource refresh notification, so that the cache device cannot use the first resource to respond to the resource request of the user terminal (the first resource matches the resource requested by the resource request); when a resource request from the user terminal is received and the first resource cannot be used to respond, a second resource that matches the resource request is obtained from the source station; the second resource is sent to the user terminal. The scheme uses regular expressions to refresh the cache resources, which can realize batch refresh of resources, and can solve the technical problem of low cache refresh efficiency in related technologies, thereby achieving the technical effect of improving refresh efficiency.

[0042] In the related art, if URL refresh is used, the customer is required to provide a list of changed resources in batches, which is more complicated to use and less efficient. If directory refresh is used, the resources that need to be changed are in multiple directories or one directory, and when some resources in the directory are changed, they cannot be accurately refreshed through one refresh instruction. There may be multiple refreshes. For example, if the html file in the / wwwroot / html directory is changed, but other files are unchanged, using directory refresh will also refresh the unchanged resources, thereby affecting the use of other resources and causing additional bandwidth pressure when refreshing these resources.

[0043] In the above scheme of the present application, in addition to improving the refresh efficiency by using regular expressions, it also has the following advantages: 1) Compared with URL refresh and directory refresh, the use of regular expressions can not only realize batch refresh, but also use attributes to accurately refresh the resources that meet the requirements, avoiding the refresh of redundant resources; 2) Only when a resource request from a user terminal is received and the first resource cannot be used to respond (that is, the first time the user terminal requests the first resource after the operation), the resource will be pulled from the source station, avoiding the excessive load on the source station caused by a large number of cache devices requesting resources from the source station at the same time. In addition, for the second and subsequent user terminal requests for the same resource, since the first resource has been refreshed locally, the refreshed resource is the second resource, and the second resource can be directly used for response, so the previously cached second resource can be directly used to respond, avoiding repeated pulling of resources from the source station; 3) When obtaining the second resource that matches the resource request from the source station, there is no need to perform back-to-source verification, but directly obtain the second resource, which can reduce the interaction with the source station, reduce the load on the source station and reduce the occupancy of the network bandwidth.

[0044] As an optional embodiment, the following is combined with the above Figure 2 The steps shown further detail the technical solution of this application:

[0045] In the technical solution provided in step S202, when the CDN refresh module needs to refresh resources, a regular expression for representing these resources is generated and sent to the CDN cache server. The CDN cache server receives the resource refresh notification and refreshes the cached resources according to the instructions of the resource refresh notification.

[0046] Optionally, after receiving the resource refresh notification, the CDN cache server processes each regular expression used in the resource refresh notification in the following manner:

[0047] Step 1: Obtain the unprocessed regular expression in the resource refresh notification, recorded as the second regular expression.

[0048] Optionally, after obtaining the second regular expression, the second regular expression can be verified. After the verification is passed, the subsequent steps are executed. If the verification fails, the CDN refresh module is notified of the refresh failure. Specifically, it can be notified that the second regular expression is illegal, so that the customer can verify the second regular expression. An optional specific verification method is as follows: Use the compile method (or compile function) to compile the second regular expression. The string form of the regular expression can be compiled into a Pattern object. If the compilation is successful, the verification is considered to be passed, otherwise the verification is considered to be failed.

[0049] It should be noted that if the domain names in the second regular expression contain a shared domain name (that is, although the domain names are different, the resources stored in the two domain names are the same, so the two domain names are each other's shared domain names), then the second regular expression also has a corresponding third regular expression (the third regular expression differs from the second regular expression only in the domain name, the domain name part of the third regular expression is the above-mentioned shared domain name, and the resources pointed to are exactly the same). The second regular expression and the third regular expression are both processed according to the following steps.

[0050] In the technical solution of the present application, the feature of shared domain name is introduced. Customers do not need to care about the same resources in various channels. They only need to update one of them to achieve synchronous update of the same resources in other channels, which greatly reduces their workload.

[0051] Step 2: Obtain a second domain name hash value of the domain name in the second regular expression.

[0052] For example, for the second regular expression http: / / 123.com / abc, the domain name is "123.com", you can use hash functions (functions that map the key values ​​of elements in a hash table to the storage locations of elements), such as MD5, SHA-1, SHA-2, SHA-224 and other functions, to calculate the second domain name hash value of the above domain name.

[0053] Optionally, in step 2, it may also include: obtaining a third domain name hash value of the domain name in the third regular expression. The specific implementation method is similar to the above content.

[0054] Step 2: If there is no element indexed by the second domain name hash value in the hash table, create a second element indexed by the second domain name hash value and using the second regular expression as the key value in the hash table.

[0055] At least one element can be stored in the hash table. Each element uses the hash value of the domain name as the index key and the regular expression that includes the domain name as the key value. It should be noted that each domain name can correspond to multiple regular expressions. In other words, users can update resources in different directories under the same domain name in multiple times (using multiple regular expressions). At this time, the keys corresponding to these multiple regular expressions are the same, and these multiple regular expressions are stored in the corresponding value. The above value can store data in the form of a linked list. When inserting a new regular expression, it can be directly inserted at the end.

[0056] Optionally, in step 2, it may also include: if there is no element with the third domain name hash value as the index in the hash table, creating an element with the third domain name hash value as the index and the third regular expression as the key value in the hash table. The specific implementation method is similar to the above content.

[0057] Step 3: If a third element indexed by the hash value of the second domain name already exists in the hash table, obtain the key value of the third element.

[0058] Optionally, step 3 may further include: if a fourth element indexed by the hash value of the third domain name already exists in the hash table, obtaining the key value of the fourth element.

[0059] Step 4: If the second regular expression does not exist in the key value of the third element, insert the second regular expression into the key value of the third element.

[0060] Optionally, step 4 may further include: if the third regular expression does not exist in the key value of the fourth element, inserting the third regular expression into the key value of the fourth element.

[0061] Step 5, when the second regular expression exists in the key value of the third element, the expiration time of the second regular expression in the key value of the third element is updated from the first moment to the second moment, the second moment is later than the first moment, and its submission time is updated to the time of this submission.

[0062] The expiration time of the regular expression can be set to T (for example, 1 day) as needed. The original expiration time of the second regular expression (i.e., the first moment) is T0+T, where T0 is the last refresh time. The changed expiration time of the second regular expression (i.e., the second moment) is T1+T, where T1 is the current refresh time.

[0063] Optionally, in step 4, the method may further include: if the third regular expression does not exist in the key value of the fourth element, inserting the third regular expression into the key value of the fourth element. The specific implementation is similar to the above content.

[0064] In the technical solution provided in step S204, in response to the resource refresh notification, the CDN cache server operates a first resource in the cache resources that matches the resource refresh notification, so that the CDN cache server cannot use the first resource to respond to the resource request of the user terminal.

[0065] Optionally, in order to prevent the CDN cache server from using the first resource to respond to the resource request of the user terminal, the first resource in the cache resource that matches the resource refresh notification may be operated in one of the following ways:

[0066] First, the first resource in the cache resource that matches the resource refresh notification is directly deleted. This method can save the storage space of the CDN cache server and improve the utilization rate of the CDN cache server.

[0067] Secondly, a first resource in the cached resources that matches the resource refresh notification is marked with a preset mark, where the preset mark is used to indicate that the marked resource cannot be used to respond to the request of the user terminal.

[0068] Optionally, the mark "01" can be used to indicate that the resource is available, and "10" can be used to indicate that the resource is unavailable. This method can save network resources in some cases. For example, when updating, if it is found that the resource (hash) of the source site is consistent with the local resource (hash), it means that the resource has not been actually updated, and the availability of the resource can be directly restored without pulling it from the source site; for example, after the client releases the update, it is found that there is a problem with the updated resource (such as a bug in the updated version of the software), and it is necessary to roll back to the previous version. At this time, the previous resource can be directly enabled locally without pulling it from the source site again.

[0069] Third, the first resource in the cache resource that matches the resource refresh notification is transferred to a preset storage location for storage, and the resource located at the preset storage location cannot be used to respond to the request of the user terminal.

[0070] Compared with the second solution mentioned above, the second solution requires additional tagging for resources, which will bring additional overhead. The third solution is to distinguish different cache directories in the CDN cache server. For example, the cache area of ​​the CDN cache server is divided into area A, area B, and area C. Area A stores currently valid resources, area B stores resources that cannot be used to respond to user terminal requests, and area C is used as a backup area. The storage space in area C can be expanded to area A or area B.

[0071] Optionally, the regular expression and the cache resource have corresponding expiration times, and the expiration time of the first resource is earlier than the expiration time of the first regular expression that matches the first resource. For the second and third technical solutions mentioned above, after operating on the first resource that matches the resource refresh notification in the cache resource of the cache device, if no update occurs for a long time, when the current time reaches the expiration time of the first resource, the first resource is deleted from the cache resource of the cache device, which can release storage space and improve the utilization rate of the storage space.

[0072] In the technical solution provided in step S206, when receiving a resource request from a user terminal and being unable to respond using the first resource, the CDN cache server obtains a second resource matching the resource request from the source site.

[0073] Optionally, the solution provided in step S206 above may be processed in the manner shown in steps 1 to 7 below:

[0074] Step 1: The CDN cache server receives a request from a user terminal.

[0075] Step 2: The CDN cache server parses the resource address URL from the request sent by the user terminal.

[0076] Step 3: The CDN cache server matches the parsed resource address with a pre-stored regular expression, where the pre-stored regular expression includes a first regular expression in the resource refresh notification that matches the first resource. The following steps 31 to 35 are included.

[0077] Step 31, obtain the first domain name hash value of the domain name in the resource address, the specific method is similar to the above, intercept the domain name field from the URL, and then use the hash algorithm to calculate its hash value.

[0078] Step 32: If there is no first element indexed by the first domain name hash value in the hash table, determine that the resource address does not match the first regular expression.

[0079] Compare the calculated first domain name hash value with the index key of each element in the hash table. If an element with the first domain name hash value as the index key is found, it is determined that the element is the first element. The specific search method can be one of the following as needed:

[0080] One is to use a single-threaded search, and use the single thread to run the search program (that is, whether the hash value of the element index key is the same as the hash value of the first domain name), and the search can be started from the head or the tail of the hash table.

[0081] The second is to use N threads to search in parallel. Assume that the entire hash table has M elements, the value of M modulo N is P, (MP) / N=Q, then each of the first P threads processes (Q+1) elements, and each of the following (NP) threads processes Q elements. The specific arrangement can be that the starting element coordinates of the i-th thread are: when the value of i is 1 to Q, (Q+1)*(i-1)+1; when the value of i is greater than Q and less than or equal to N, (Q+1)*P+Q*(iP-1)+1, N, P, Q, M, i are all integers.

[0082] Using a parallel approach can greatly improve processing efficiency.

[0083] Step 33: If there is a first element with the first domain name hash value as the index key in the hash table, obtain the key value of the first element.

[0084] Step 34: If the resource address is not within the address range represented by any regular expression in the key value of the first element, determine that the resource address does not match the first regular expression.

[0085] The key value of the first element may include multiple regular expressions. When comparing the resource address URL with the regular expression, the regular expression may be a URL representing a specific resource. In this case, the two can be directly compared to see if they are the same. The regular expression may also be information representing a resource directory. In this case, it can be checked whether the resource address URL falls within the directory (i.e., the range). If so, it is confirmed that the two match successfully. Otherwise, the match fails and other regular expressions continue to be matched.

[0086] Step 35: When the resource address is within the address range represented by the first regular expression in the key value of the first element, determine that the resource address matches the first regular expression.

[0087] Step 4: When the parsed resource address matches the first regular expression, determine that the request sent by the user terminal is a resource request (ie, a request for the first resource).

[0088] Step 5: Get the expiration time of the first regular expression.

[0089] Step 6: When the current time reaches the expiration time, the first regular expression is deleted from the key value of the first element, and it is matched with the regular expressions in the remaining elements in the hash table in the same way.

[0090] After deleting the first regular expression, if there is no other matching regular expression, check whether there is a resource matching the resource request locally. If so, use the cached resource for feedback; if not, pull it from the source site according to the resource request.

[0091] Step 7: When the current time does not reach the expiration time of the first regular expression, obtain the second resource from the source station according to the resource address indicated by the resource request.

[0092] By configuring an expiration time for a regular expression, you can reduce the matching time when matching with resource requests (expired regular expressions will be deleted and will not be involved in subsequent matching), thereby improving matching efficiency.

[0093] Optionally, after obtaining the second resource matching the resource request from the source station and caching the second resource, if the user requests the second resource, it can be processed in the manner shown in the following steps 1 to 6:

[0094] Step 1: The CDN cache server receives a second request from a user terminal.

[0095] Step 2: The CDN cache server resolves the resource address from the second request of the user terminal.

[0096] Step 3: When the resource address parsed in the second request matches the first regular expression, the CDN cache server obtains the expiration time of the first regular expression.

[0097] Step 4: When the current time does not reach the expiration time, the CDN cache server obtains a second resource on the cache device that matches the resource address resolved in the second request.

[0098] Step 5: When the cache time of the second resource is later than the reception time of the first regular expression, the CDN cache server sends the second resource to the user terminal.

[0099] The reason why the cache time of the second resource and the receiving time of the first regular expression are compared here is that the refresh time of the first regular expression may change at any time. For example, the client updates the resource of the target URL (that is, the URL of the first resource) twice in a period of time, then two resource refresh notifications will be sent (both carrying the first regular expression). The above steps are equivalent to completing the resource refresh after the first resource refresh notification. However, after refreshing the resource this time, the user needs to refresh the resource again. That is, the receiving time of the first regular expression becomes the receiving time of the second resource refresh notification after the first resource refresh. In other words, the second resource at this time is no longer the latest resource and needs to be refreshed again.

[0100] Step 6: When the cache time of the second resource is not later than the reception time of the first regular expression, the CDN cache server re-pulls the matching resource from the source station according to the second request, and then sends the pulled resource to the user terminal.

[0101] In the technical solution provided in step S208, the CDN cache server sends the second resource to the user terminal. After that, if the CDN cache server receives a request from the user terminal again, and the second resource cached on the cache device matches the resource requested by the request (the URL in the request is the same as the second resource), the second resource is directly sent to the user terminal.

[0102] As another optional embodiment, the following is combined with the above Figure 3 The steps shown further detail the technical solution of this application:

[0103] Step S302: The CDN cache server receives a resource refresh notification, where the resource refresh notification uses a regular expression to indicate that the cached resources are to be refreshed.

[0104] Optionally, after receiving the resource refresh notification, each regular expression used in the resource refresh notification can be processed in the following manner: obtain an unprocessed second regular expression from the resource refresh notification; verify the second regular expression, and if the verification passes, obtain the second domain name hash value of the domain name in the second regular expression used in the resource refresh notification, where the second regular expression is an unprocessed regular expression in the resource refresh notification; if there is no element indexed by the second domain name hash value in the hash table, create a second element indexed by the second domain name hash value and with the second regular expression as the key value in the hash table; if there is a third element indexed by the second domain name hash value in the hash table, obtain the key value of the third element; if the second regular expression does not exist in the key value of the third element, insert the second regular expression into the key value of the third element; if the second regular expression exists in the key value of the third element, update the expiration time of the second regular expression in the key value of the third element from the first moment to the second moment, where the second moment is later than the first moment.

[0105] Step S304: In response to the resource refresh notification, the CDN cache server deletes the first resource in the cached resources that matches the resource refresh notification.

[0106] Step S306: When receiving a resource request from a user terminal and being unable to respond with a first resource that matches the resource request, the CDN cache server obtains a second resource that matches the resource request from the source site.

[0107] Optionally, the request sent by the user terminal can be determined to be a resource request in the following manner: a resource address is parsed from the request sent by the user terminal; the parsed resource address is matched with a pre-stored regular expression, the pre-stored regular expression includes a first regular expression in the resource refresh notification that matches the first resource; when the parsed resource address matches the first regular expression, it is determined that the request sent by the user terminal is a resource request.

[0108] Optionally, the parsed resource address is matched with a pre-stored regular expression, including: obtaining a first domain name hash value of the domain name in the resource address; if there is no first element indexed by the first domain name hash value in the hash table, determining that the resource address does not match the first regular expression, wherein each element in the hash table is indexed by the hash value of the domain name and has a regular expression including the domain name as a key value; if there is a first element indexed by the first domain name hash value in the hash table, obtaining the key value of the first element; if the resource address is not located within the address range represented by any regular expression in the key value of the first element, determining that the resource address does not match the first regular expression; if the resource address is located within the address range represented by the first regular expression in the key value of the first element, determining that the resource address matches the first regular expression.

[0109] Optionally, when a resource request from a user terminal is received and the first resource cannot be used to respond, a second resource matching the resource request is obtained from the source station, including: when a resource request from a user terminal is received and the first resource cannot be used to respond, obtaining the expiration time of the first regular expression; when the current time does not reach the expiration time of the first regular expression, obtaining the second resource from the source station according to the resource address indicated by the resource request.

[0110] When the current time reaches the expiration time, the first regular expression is deleted from the key value of the first element.

[0111] Step S308: The CDN cache server sends the second resource to the user terminal.

[0112] Optionally, after sending the second resource to the user terminal, receiving a first request from the user terminal; when the second resource cached on the cache device matches the resource requested by the first request, directly sending the cached second resource to the user terminal.

[0113] Optionally, after obtaining a second resource matching the resource request from the source station and caching the second resource, receiving a second request from the user terminal; parsing a resource address from the second request of the user terminal; obtaining an expiration time of the first regular expression when the resource address parsed in the second request matches the first regular expression; obtaining a second resource on the cache device that matches the resource address parsed in the second request when the current time has not reached the expiration time; and sending the second resource to the user terminal when the cache time of the second resource is later than the reception time of the first regular expression.

[0114] As another optional embodiment, the technical solution of the present application is further described in detail below in combination with specific steps:

[0115] Step 1: The CDN cache server receives a directory refresh notification.

[0116] The resource refresh notification is sent by the CDN refresh module. The CDN refresh module can be a separate server for centrally processing resource refresh notifications. When running, it receives resource refresh notifications sent by each client side and forwards them to each CDN cache server. The CDN refresh module can be integrated on the CDN source station as an auxiliary function of the CDN source station. The CDN refresh module can also be integrated on the client server as an auxiliary function on the client server side, and the client triggers the refresh. It is understandable that the directory refresh notification received by the CDN cache server can be notified by the source station, or it can be notified by the client to the CDN manufacturer's staff, and the CDN manufacturer's staff will send the directory refresh notification to the CDN cache server according to the customer's notification requirements.

[0117] Step 2, in response to the directory refresh notification, the CDN cache server operates the third resource in the cache resources of the cache device that matches the directory refresh notification, so that the cache device cannot use the third resource to respond to the resource request of the user terminal, and the third resource matches the resource requested by the resource request.

[0118] After receiving the directory refresh notification, it can be inserted into the data structure in the memory (dictionary tree or optimized dictionary-like tree structure), and then respond to the client for a successful refresh, without reducing the failure of the refresh. At the same time, the CDN cache server operates the third resource in the cache resources of the cache device that matches the directory refresh notification, which can be to delete the third resource or set the third resource to an expired state, so that the cache device cannot use the third resource to respond to the user when receiving the resource request from the user terminal. After operating on the third resource, the directory refresh notification is deleted. Dynamically deleting the target refresh notification can reduce the directory refresh notification stored by the cache server, thereby reducing the matching time between the user terminal resource request and the directory refresh notification stored by the cache server. In an embodiment of the present application, since the third resource is operated, the cache device cannot use the third resource to respond to the resource request of the user terminal, so that even if the directory refresh notification is deleted, the cache server will not send the third resource to the user terminal.

[0119] Step 3: When the CDN cache server receives the resource request from the user terminal and cannot respond using the third resource, it obtains a fourth resource matching the resource request from the source site.

[0120] In the embodiment of the present application, if the resource request of the user terminal indicates a request to obtain a third resource, at this time, the CDN cache server will match the resource request of the user terminal with the directory refresh notification stored in itself. If the match is successful, the refreshed file is obtained from the source station and sent to the user terminal. If the match fails, it is possible that the corresponding directory refresh notification was deleted after the operation on the third resource in step 2. At this time, since the third resource has been operated, the CDN cache server cannot use the third resource to respond to the user terminal. Therefore, even if the match fails, the CDN cache server will go back to the source and obtain the fourth resource that matches the resource request from the source station and send it to the user terminal.

[0121] Step 4: The CDN cache server sends the fourth resource to the user terminal.

[0122] In an embodiment of the present application, each time a new resource is created by the CDN cache server (i.e., a resource obtained from the source site is cached on the CDN cache server, such as the fourth resource mentioned above), the URL corresponding to the resource is written into a file on the disk, and the file is regularly inserted into an ordered db file (a database file). All resources cached by the CDN cache server are maintained through the db file.

[0123] In an embodiment of the present application, the CDN cache server can periodically take out a directory from the data structure in the memory (derived from the user's directory refresh notification), and obtain all cached resources under this directory from the ordered db file, and actively refresh them one by one (actively delete the resources that need to be refreshed or actively set their expiration time to 0 to ensure that the next time the netizen visits, the CDN will go back to the source to obtain the updated resources). After all the resources under this directory are refreshed, this directory will be deleted from the data structure in the memory, thereby ensuring that only a small number of unprocessed refresh directories are stored in the memory. Memory consumption can be reduced through active refresh.

[0124] In an embodiment of the present application, the CDN cache server can also regularly slim down the db file. In order to ensure the validity of the db file, during the low traffic period, all resources in the db file are checked one by one to see if they are still in the CACHE cache. If the resource is no longer in the CACHE cache (such as no access after refresh or LRU elimination), the resource is deleted from the ordered db file, thereby ensuring that the resources in the db file are valid records, preventing the accumulation of invalid records from causing the db file to become larger and larger.

[0125] The method of the embodiment of the present application can support both active and passive directory refresh solutions, and directory refresh does not need to be triggered by netizens' requests; the existence cycle of the refresh directory in the memory is reduced, memory consumption is reduced, and more directory refreshes can be provided at the same time.

[0126] It should be noted that Figure 3 The specific implementation methods of the steps shown are Figure 2 The specific implementation methods of the steps shown are similar. For specific implementation, please refer to the above and will not be repeated here.

[0127] The technical solution of this application supports regular refresh. Customers can provide regular expressions to be refreshed to achieve a one-time batch refresh of all cached resources that meet certain characteristics. The CDN cache server will delete the resources that meet the regular expression, and when subsequent netizens visit, they will go back to the source to obtain the updated resources. As an optional embodiment, Figure 4 As shown, the technical solution of the present application is further described in detail below in conjunction with specific implementation methods:

[0128] In step 41, the client (the client using CDN service) submits a regular refresh request (i.e., resource refresh notification) to the CDN refresh center, i.e., the CDN refresh module. The CDN refresh center is the entry point for receiving the client's regular refresh request. After receiving it, it distributes the refresh request to all CACHE devices (i.e., CDN cache servers) to refresh the cache. The client origin site refers to the place where the content is generated and stored. The cached content of the CDN cache server is obtained from the client origin site.

[0129] Step 42, the CDN refresh center performs verification processing, and after the verification is passed, the regular refresh request (which can be a regular expression including the URL) is sent to the CACHE system of all CDN devices, including multiple CDN cache servers, each of which can include a high-performance HTTP and reverse proxy web server NGINX and cache CACHE.

[0130] The above verification process is a one-time verification, including verification of whether the regular expression is legal, whether the number of regular refreshes submitted by the customer exceeds the threshold, whether the customer has the operation authority to refresh the domain name, etc.

[0131] Step 43, the CACHE system performs a second check on the legality of the regular expression to prevent the client from submitting an incorrect regular expression. If the check fails (such as the regular expression is illegal), a refresh failure is directly returned; if the check succeeds, the process continues.

[0132] The purpose of the above secondary verification is to verify whether the regular expression is legal. A compile operation can be performed on it. If the operation is successful, it is determined that the regular expression is legal. If it is unsuccessful, it is determined that the regular expression is illegal.

[0133] Step 44, the CACHE system uses the domain name field in the regular expression as the key to calculate the hash, and then checks whether the regular expression already exists. If so, it updates its expiration time and returns; if not, it compiles the regular expression and inserts it into the hash table (the regular expression submitted by the customer is saved in the hash table, the key is the host field in the regular expression, and multiple regular expressions with the same key are stored in a linked list), and returns to the refresh center to indicate that the regular refresh has been executed successfully.

[0134] The regular refresh used in this application is a passive refresh, that is, the resource will only be judged whether it hits the regular refresh when it is accessed, so an expiration time will be set for the regular refresh rule submitted by the customer (such as saving for 1 month) to ensure that the resources that need to be refreshed will be refreshed.

[0135] Step 45, when receiving a request from an Internet user, if the resource is not found locally, it is processed according to the original logic; if it is found, it is checked according to the following method to see if it is found regularly and refreshed.

[0136] Step 451, calculate the hash according to the domain name in the request URL (the resource storage URL carried in the request), and search in the hash table whether there is a regular refresh list for this domain name.

[0137] If it does not exist and there is no need to compare the storage URL corresponding to the request URL, it will directly return a missed regular refresh and use the local cache to provide services normally, otherwise it will continue. Regular refresh is stored in a hash table, and then a linked list is used to resolve conflicts, that is, first determine whether the value corresponding to the key exists. If it does not exist, it means that this domain name has not submitted a regular refresh, and it will directly return to continue processing; if the value exists, it is necessary to compare all regular expressions in the value.

[0138] Step 452, perform regular matching on the stored URL corresponding to the request URL and the regular expressions obtained in the previous step one by one. If no match is successful, return a miss regular refresh, and the local cache can provide services normally; if a match is successful, continue.

[0139] The storage URL is used to identify resources within the CDN. For example, if domain name a and domain name b share the cache, it means

[0140] http: / / a / 1.html and http: / / b / 1.html are the same resource. If b is set to share the resource of a, then

[0141] The storage URL corresponding to http: / / b / 1.html is http: / / a / 1.html.

[0142] Step 453, if the regular refresh is hit, determine whether the regular refresh rule is expired (set a fixed time from submission, such as 1 month expiration). If it has expired, delete the regular refresh rule and continue with the remaining regular expression matching in step 452; if it has not expired, continue.

[0143] Step 454, compare the time when the resource is cached locally with the submission time of the regular refresh. If the time when the resource is cached locally is later than the submission time of the regular refresh, a regular refresh is returned as missed, and the local cache can continue to provide services; otherwise, continue. Before the regular refresh submits this refresh request to CACHE, the resources cached by CACHE take effect, which ensures that the resource is only refreshed once and can be hit normally later. For example, if resource A is cached first, and the client submits a regular refresh, the existing cache will be deleted when resource A is accessed again, and then it will be retrieved from the source again. When resource A is accessed later, it will be directly hit from the local cache without deleting and re-acquiring.

[0144] The regular expression expiration time must be greater than the disk rotation cycle (that is, the time period after which a resource will be naturally eliminated if it is not accessed). For example, if the regular expression expiration time is 1 month and the disk rotation cycle is 2 weeks, it can be ensured that a resource will be eliminated (deleted from the disk) if it is not accessed for 2 consecutive weeks. In this way, even if the regular expression expires after 1 month, the resource will not be hit and will be retrieved from the source again.

[0145] Step 455: If the regular refresh rule is hit and the resource is cached before the regular refresh is submitted, the CDN needs to delete the resource and obtain it from the origin again.

[0146] In the technical solution of the present application, regular expression refresh is supported. Resources that are cached before refresh and match the regular expression are directly deleted and retrieved from the source again. Customers can control the refresh range according to the regular expression to achieve more accurate batch resource refresh. Hash is performed according to the domain name, and regular expression refreshes for different domain names are stored separately to reduce invalid regular expression matches when requesting a domain name and reduce processing time.

[0147] 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.

[0148] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0149] According to another aspect of an embodiment of the present application, a cache resource refresh device for implementing the above-mentioned cache resource refresh method is also provided. Figure 5 is a schematic diagram of an optional cache resource refresh device according to an embodiment of the present application, such as Figure 5 As shown, the device may include:

[0150] A first receiving unit 51 is used to receive a resource refresh notification, wherein the resource refresh notification uses a regular expression to indicate refreshing of cache resources;

[0151] A first processing unit 53 is configured to, in response to the resource refresh notification, operate a first resource in the cache resources of the cache device that matches the resource refresh notification, so that the cache device cannot respond to the resource request of the user terminal using the first resource, wherein the first resource matches the resource requested by the resource request;

[0152] A first refreshing unit 55 is configured to, upon receiving the resource request from the user terminal and failing to respond using the first resource, obtain a second resource matching the resource request from the source station;

[0153] The first sending unit 57 is configured to send the second resource to a user terminal.

[0154] It should be noted that the first receiving unit 51 in this embodiment can be used to execute step S202 in the embodiment of the present application, the first processing unit 53 in this embodiment can be used to execute step S204 in the embodiment of the present application, the first refresh unit 55 in this embodiment can be used to execute step S206 in the embodiment of the present application, and the first sending unit 57 in this embodiment can be used to execute step S208 in the embodiment of the present application.

[0155] Through the above modules, 1) the cache resources are refreshed by using regular expressions, which can realize batch refresh of resources, solve the technical problem of low cache refresh efficiency in related technologies, and thus achieve the technical effect of improving refresh efficiency; 2) compared with URL refresh and directory refresh, the use of regular expressions can not only realize batch refresh, but also accurately refresh the specified type of resources, avoiding the refresh of redundant resources; 3) only when a resource request from a user terminal is received and the first resource cannot be used to respond (that is, the first resource is requested by the user terminal for the first time after the first resource is operated), the resource is refreshed from the source. The first resource is refreshed locally, and the refreshed resource is the second resource. The second resource can be used directly for response. Therefore, the second resource cached previously can be used directly for response, avoiding repeated resource pulling from the source station. 4) When obtaining the second resource that matches the resource request from the source station, there is no need to perform back-to-source verification, but directly obtain the second resource, which can reduce the interaction with the source station, reduce the load on the source station and reduce the occupancy of the network bandwidth.

[0156] Optionally, when operating the first resource in the cache resource of the cache device that matches the resource refresh notification, the first processing unit is further configured to: delete the first resource in the cache resource that matches the resource refresh notification.

[0157] Optionally, when the first processing unit operates on the first resource in the cache resource of the cache device that matches the resource refresh notification, it is also used to: mark the first resource in the cache resource that matches the resource refresh notification with a preset mark, wherein the preset mark is used to indicate that the marked resource cannot be used to respond to the request of the user terminal.

[0158] Optionally, when the first processing unit operates on the first resource in the cache resource of the cache device that matches the resource refresh notification, it is also used to: transfer the first resource in the cache resource that matches the resource refresh notification to a preset storage location for storage, wherein the resource located at the preset storage location cannot be used to respond to the request of the user terminal.

[0159] Optionally, the first sending unit is also used to: after sending the second resource to the user terminal, receive a first request from the user terminal; and when the second resource cached on the cache device matches the resource requested by the first request, directly send the cached second resource to the user terminal.

[0160] Optionally, the first refresh unit is also used to determine that the request sent by the user terminal is the resource request in the following manner: parse the resource address from the request sent by the user terminal; match the parsed resource address with a pre-stored regular expression, wherein the pre-stored regular expression includes a first regular expression in the resource refresh notification that matches the first resource; and when the parsed resource address matches the first regular expression, determine that the request sent by the user terminal is the resource request.

[0161] Optionally, when matching the parsed resource address with a pre-stored regular expression, the first refresh unit is further used to: obtain a first domain name hash value of the domain name in the resource address; if there is no first element indexed by the first domain name hash value in the hash table, determine that the resource address does not match the first regular expression, wherein each element in the hash table is indexed by the hash value of the domain name and has a regular expression including the domain name as a key value; if there is a first element indexed by the first domain name hash value in the hash table, obtain the key value of the first element; if the resource address is not located within the address range represented by any regular expression in the key value of the first element, determine that the resource address does not match the first regular expression; if the resource address is located within the address range represented by the first regular expression in the key value of the first element, determine that the resource address matches the first regular expression.

[0162] Optionally, after receiving the resource refresh notification, the first processing unit is further used to process each regular expression used in the resource refresh notification in the following manner: obtain a second domain name hash value of the domain name in a second regular expression used in the resource refresh notification, wherein the second regular expression is a regular expression that has not been processed in the resource refresh notification; when there is no element indexed by the second domain name hash value in the hash table, create a second element indexed by the second domain name hash value and using the second regular expression as a key value in the hash table; when there is a third element indexed by the second domain name hash value in the hash table, obtain the key value of the third element; when the second regular expression does not exist in the key value of the third element, insert the second regular expression into the key value of the third element; when the second regular expression exists in the key value of the third element, update the expiration time of the second regular expression in the key value of the third element from the first moment to the second moment, wherein the second moment is later than the first moment.

[0163] Optionally, the first processing unit is also used to obtain an unprocessed second regular expression from the resource refresh notification before obtaining the second domain name hash value of the domain name in the second regular expression adopted by the resource refresh notification; and verify the second regular expression, wherein, if the verification passes, the second domain name hash value of the domain name in the second regular expression adopted by the resource refresh notification is obtained.

[0164] Optionally, when the first refresh unit receives the resource request from the user terminal and cannot respond using the first resource, it obtains the second resource matching the resource request from the source station. The first refresh unit is also used to: when the resource request from the user terminal is received and the first resource cannot be responded using, obtain the expiration time of the first regular expression; when the current time does not reach the expiration time of the first regular expression, obtain the second resource from the source station according to the resource address indicated by the resource request.

[0165] Optionally, the first refresh unit is further configured to, after acquiring the expiration time of the first regular expression, delete the first regular expression from the key value of the first element when the current time reaches the expiration time.

[0166] Optionally, the first sending unit is also used to receive a second request from the user terminal after obtaining a second resource matching the resource request from the source station and caching the second resource; parse the resource address from the second request of the user terminal; when the resource address parsed in the second request matches the first regular expression, obtain the expiration time of the first regular expression; when the current time does not reach the expiration time, obtain the second resource on the cache device that matches the resource address parsed in the second request; when the cache time of the second resource is later than the receiving time of the first regular expression, send the second resource to the user terminal.

[0167] Optionally, the first processing unit is also used to, after operating a first resource in the cache resources of the cache device that matches the resource refresh notification, delete the first resource from the cache resources of the cache device when the current time reaches the expiration time of the first resource, wherein the expiration time of the first resource is earlier than the expiration time of a first regular expression that matches the first resource.

[0168] According to another aspect of an embodiment of the present application, a cache resource refresh device for implementing the above-mentioned cache resource refresh method is also provided. Figure 6 is a schematic diagram of an optional cache resource refresh device according to an embodiment of the present application, such as Figure 6 As shown, the device may include:

[0169] A second receiving unit 61 is used to receive a resource refresh notification, wherein the resource refresh notification uses a regular expression to indicate refreshing of cache resources;

[0170] A second processing unit 63 is configured to delete, in response to the resource refresh notification, a first resource in the cache resources of the cache device that matches the resource refresh notification;

[0171] The second refreshing unit 65 is configured to, upon receiving a resource request from a user terminal and failing to respond with the first resource matching the resource request, obtain a second resource matching the resource request from a source station;

[0172] The second sending unit 67 is configured to send the second resource to a user terminal.

[0173] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 1 In the hardware environment shown, it can be implemented by software or by hardware, wherein the hardware environment includes a network environment.

[0174] According to another aspect of an embodiment of the present application, a server or terminal for implementing the above-mentioned cache resource refresh method is also provided.

[0175] Figure 7 is a structural block diagram of a terminal according to an embodiment of the present application, such as Figure 7 As shown, the terminal may include: one or more ( Figure 7 (only one is shown) processor 701, memory 703, and transmission device 705, as shown in Figure 7 As shown, the terminal may also include an input and output device 707.

[0176] Among them, the memory 703 can be used to store software programs and modules, such as the program instructions / modules corresponding to the method and device for refreshing cache resources in the embodiment of the present application. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory 703, that is, realizing the above-mentioned method for refreshing cache resources. The memory 703 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 703 may further include a memory remotely arranged relative to the processor 701, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0177] The above-mentioned transmission device 705 is used to receive or send data via a network, and can also be used for data transmission between a processor and a memory. Specific examples of the above-mentioned network may include a wired network and a wireless network. In one example, the transmission device 705 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 705 is a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly.

[0178] Specifically, the memory 703 is used to store application programs.

[0179] The processor 701 may call the application stored in the memory 703 through the transmission device 705 to perform the following steps:

[0180] Receive a resource refresh notification, the resource refresh notification uses a regular expression to indicate that the cache resources are to be refreshed; in response to the resource refresh notification, operate on a first resource in the cache resources of the cache device that matches the resource refresh notification, so that the cache device cannot use the first resource to respond to the resource request of the user terminal, and the first resource matches the resource requested by the resource request; when a resource request from the user terminal is received and the first resource cannot be used to respond, obtain a second resource that matches the resource request from the source station; and send the second resource to the user terminal.

[0181] The processor 701 is further configured to execute the following steps:

[0182] Receive a resource refresh notification, which uses a regular expression to indicate that the cache resources are to be refreshed; in response to the resource refresh notification, delete the first resource that matches the resource refresh notification in the cache resources of the cache device; when a resource request from a user terminal is received and the first resource that matches the resource request cannot be used to respond, obtain a second resource that matches the resource request from the source station; and send the second resource to the user terminal.

[0183] By using the embodiments of the present application, 1) the cache resources are refreshed by using a regular expression method, which can realize batch refresh of resources, and can solve the technical problem of low cache refresh efficiency in related technologies, thereby achieving the technical effect of improving refresh efficiency; 2) compared with URL refresh and directory refresh, the use of regular expressions can not only realize batch refresh, but also accurately refresh the resources of the specified type, avoiding the refresh of redundant resources; 3) only when a resource request from a user terminal is received and the first resource cannot be used to respond (that is, the first resource is requested by the user terminal for the first time after the first resource is operated), the resource is refreshed from the first resource. The source station pulls resources, avoiding excessive load on the source station caused by a large number of cache devices requesting resources from the source station at the same time. In addition, for the second and subsequent user terminal requests for the same resource, since the first resource has been refreshed locally, the refreshed resource is the second resource, and the second resource can be used directly for response, so the previously cached second resource can be directly used for response, avoiding repeated pulling of resources from the source station; 4) When obtaining the second resource that matches the resource request from the source station, there is no need to perform back-to-source verification, but directly obtain the second resource, which can reduce the interaction with the source station, reduce the load on the source station and reduce the occupancy of network bandwidth.

[0184] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0185] It can be understood by those skilled in the art that Figure 7 The structure shown is for illustration only, and the terminal may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Figure 7 It does not limit the structure of the above electronic device. For example, the terminal may also include Figure 7 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 7 Different configurations shown.

[0186] A person of ordinary skill 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 the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0187] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to execute the program code of the method for refreshing cache resources.

[0188] Optionally, in this embodiment, the storage medium may be located on at least one network device among a plurality of network devices in the network shown in the above embodiment.

[0189] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps:

[0190] Receive a resource refresh notification, the resource refresh notification uses a regular expression to indicate that the cache resources are to be refreshed; in response to the resource refresh notification, operate on a first resource in the cache resources of the cache device that matches the resource refresh notification, so that the cache device cannot use the first resource to respond to the resource request of the user terminal, and the first resource matches the resource requested by the resource request; when a resource request from the user terminal is received and the first resource cannot be used to respond, obtain a second resource that matches the resource request from the source station; and send the second resource to the user terminal.

[0191] Optionally, the storage medium is further configured to store program codes for executing the following steps:

[0192] Receive a resource refresh notification, which uses a regular expression to indicate that the cache resources are to be refreshed; in response to the resource refresh notification, delete the first resource that matches the resource refresh notification in the cache resources of the cache device; when a resource request from a user terminal is received and the first resource that matches the resource request cannot be used to respond, obtain a second resource that matches the resource request from the source station; and send the second resource to the user terminal.

[0193] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.

[0194] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.

[0195] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0196] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, 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, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.

[0197] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0198] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, 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, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0199] 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.

[0200] 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.

[0201] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for refreshing cache resources, It is characterized in that include: Receive a resource refresh notification, wherein the resource refresh notification uses a regular expression to indicate refreshing of cache resources; In response to the resource refresh notification, operating a first resource in the cache resources of the cache device that matches the resource refresh notification, so that the cache device cannot respond to the resource request of the user terminal using the first resource, wherein the first resource matches the resource requested by the resource request; Upon receiving the resource request from the user terminal and failing to respond using the first resource, acquiring a second resource matching the resource request from the source station; sending the second resource to a user terminal; After receiving the resource refresh notification, the method further includes: processing each regular expression used in the resource refresh notification in the following manner: Processing a second regular expression used in the resource refresh notification to update the second regular expression into a hash table or to update an expiration time of the second regular expression in the hash table, wherein each element in the hash table is indexed by a hash value of a domain name and a regular expression including the domain name as a key value, and the second regular expression is a regular expression that has not been processed in the resource refresh notification; Processing the second regular expression used in the resource refresh notification includes: Obtaining a second domain name hash value of the domain name in a second regular expression used in the resource refresh notification; If there is no element with the second domain name hash value as an index in the hash table, create a second element with the second domain name hash value as an index and the second regular expression as a key value in the hash table; If a third element with the second domain name hash value as an index already exists in the hash table, obtaining a key value of the third element; If the second regular expression does not exist in the key value of the third element, insert the second regular expression into the key value of the third element; When the second regular expression exists in the key value of the third element, updating the expiration time of the second regular expression in the key value of the third element from the first moment to the second moment, wherein the second moment is later than the first moment; After receiving the resource refresh notification, the method further includes: In the case where the domain name in the second regular expression used in the resource refresh notification includes a shared domain name, a third regular expression is obtained, wherein two domain names storing the same resource are each other's shared domain names, and the domain name in the third regular expression and the domain name in the second regular expression are shared domain names; The third regular expression is processed in the same manner as the second regular expression.

2. The method according to claim 1, It is characterized in that The operating the first resource in the cache resources of the cache device that matches the resource refresh notification includes one of the following: Deleting the first resource in the cache resource that matches the resource refresh notification; Marking the first resource in the cache resource that matches the resource refresh notification with a preset mark, wherein the preset mark is used to indicate that the marked resource cannot be used to respond to a request of a user terminal; The first resource in the cache resource that matches the resource refresh notification is transferred to a preset storage location for storage, wherein the resource located at the preset storage location cannot be used to respond to a request from a user terminal.

3. The method according to claim 1, It is characterized in that After sending the second resource to the user terminal, the method further includes: receiving a first request from a user terminal; When the second resource cached in the cache device matches the resource requested by the first request, the cached second resource is directly sent to the user terminal.

4. The method according to claim 1, It is characterized in that The regular expression used by the resource refresh notification includes one or more regular character strings, wherein before operating a first resource in the cache resources of the cache device that matches the resource refresh notification, the method further includes determining the first resource in the following manner: All resources matching the resource addresses in the rule string are matched from the cache resources of the cache device, and the first resource matching the attribute information in the rule string is filtered out from all the matched resources.

5. The method according to claim 2, It is characterized in that After operating a first resource in a cache resource of the cache device that matches the resource refresh notification, the method further includes: When the current time reaches the expiration time of the first resource, the first resource is deleted from the cache resources of the cache device, wherein the expiration time of the first resource is earlier than the expiration time of a first regular expression matching the first resource.

6. A cache resource refresh device, It is characterized in that include: A first receiving unit, configured to receive a resource refresh notification, wherein the resource refresh notification uses a regular expression to indicate refreshing of cache resources; a first processing unit, configured to, in response to the resource refresh notification, operate a first resource in the cache resources of the cache device that matches the resource refresh notification, so that the cache device cannot respond to the resource request of the user terminal using the first resource, wherein the first resource matches the resource requested by the resource request; A first refreshing unit, configured to, upon receiving the resource request from the user terminal and failing to respond using the first resource, obtain a second resource matching the resource request from the source station; A first sending unit, configured to send the second resource to a user terminal; After receiving the resource refresh notification, the cache resource refresh device is further used to: process each regular expression used in the resource refresh notification in the following manner: Processing a second regular expression used in the resource refresh notification to update the second regular expression into a hash table or to update an expiration time of the second regular expression in the hash table, wherein each element in the hash table is indexed by a hash value of a domain name and a regular expression including the domain name as a key value, and the second regular expression is a regular expression that has not been processed in the resource refresh notification; Obtaining a second domain name hash value of the domain name in a second regular expression used in the resource refresh notification; If there is no element with the second domain name hash value as an index in the hash table, create a second element with the second domain name hash value as an index and the second regular expression as a key value in the hash table; If a third element with the second domain name hash value as an index already exists in the hash table, obtaining a key value of the third element; If the second regular expression does not exist in the key value of the third element, insert the second regular expression into the key value of the third element; When the second regular expression exists in the key value of the third element, updating the expiration time of the second regular expression in the key value of the third element from the first moment to the second moment, wherein the second moment is later than the first moment; After receiving the resource refresh notification, the cache resource refresh device is further used to: In the case where the domain name in the second regular expression used in the resource refresh notification includes a shared domain name, a third regular expression is obtained, wherein two domain names storing the same resource are each other's shared domain names, and the domain name in the third regular expression and the domain name in the second regular expression are shared domain names; The third regular expression is processed in the same manner as the second regular expression.

7. A storage medium, It is characterized in that The storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 5 when executed.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that The processor executes the method described in any one of claims 1 to 5 through the computer program.

Citation Information

Patent Citations

  • Source station file updating and releasing method and cache file updating method

    CN103200278A

  • Method and device for acquiring domain suffix

    CN106357831A

  • Method and device for allocating service scheduling in CDN node, and storage medium

    CN109542613A

  • Efficient CDN fragment refreshing method

    CN113691581A

  • Cache resource refreshing method, device and system

    CN113886743A