Resource response method, device, and readable storage medium

By using a combination of first-level and second-level keywords to cache resource files in the cache server, the problems of high storage capacity and low hit rate caused by the Vary caching mechanism are solved, achieving efficient caching and fast response of resource files.

CN116233248BActive Publication Date: 2025-11-07CHINANETCENT TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310099442.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-09
Publication Date
2025-11-07
Estimated Expiration
2043-02-09

AI Technical Summary

Technical Problem

Existing caching servers use the Vary caching mechanism when caching resource files, resulting in an infinite number of resource files for the same URL. This leads to high storage consumption and low hit rate, especially when the origin server does not provide the ETag response header. This makes the server vulnerable to malicious attacks and consumes a lot of storage resources.

Method used

By caching resource files based on the first-level keyword of the URL and ignoring the query string, and using a combination of first-level and second-level keywords for caching, the storage capacity requirements of the cache server are reduced, the resource file hit rate is improved, and the reliance on the ETag response header provided by the origin server is avoided.

Benefits of technology

This ensures that the number of resource files with the same URL on the cache server is at most equal to the number of resource files on the origin server, reducing storage capacity requirements, improving resource file hit rate, and reducing pressure on the origin server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116233248B_ABST
    Figure CN116233248B_ABST
Patent Text Reader

Abstract

The application discloses a resource response method, device and readable storage medium. After a cache server receives a request message for requesting a target resource file, a first keyword is determined according to the request message. When the cache server has cached at least one resource file in a resource file set corresponding to the first keyword, the target resource file is determined from the resource file set, and the target resource file is responded to a terminal device. The resource file set is used for storing resource files provided by a source station for a target URL. By using the scheme, the number of resource files of the same URL on the cache server is equal to the number of resource files on the source server, and the source server does not need to provide an Etag response header, so that the requirement for the storage capacity of the cache server is reduced, and the resource file hit rate is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of communication, in particular to a resource response method, device and readable storage medium. BACKGROUND

[0002] At present, a cache server is deployed in a network, and various resource files pulled from a source server are cached on the cache server. When a user requests a resource file, the user request is directed to the nearby cache server, so that the user can obtain the resource file nearby, thereby reducing network congestion and improving user access response speed and hit rate.

[0003] Generally, a server caches resource files according to a uniform resource locator (URL), and one URL corresponds to one or more resource files. For example, one URL corresponds to two resource files, one of which is used to respond to a PC browser and the other of which is used to respond to a mobile browser. That is, when a PC browser and a mobile browser request a resource file for the same URL, the cache server responds to different resource files. The cache server adopts a Vary caching mechanism. Based on the mechanism, when the cache server receives a resource request of a user, if the local does not cache the resource file expected by the user, the cache server forwards the resource request to the source server. The source server sends a resource response to the cache server, and the resource response carries a Vary response header and a resource file, and the Vary response header specifies the value of the request header (referred to as Vary value). The cache server caches the correspondence between the value of the request header and the resource file. For example, the Vary response header specifies that the request header is Accept-Encoding, and the value is gzip, and the cache server caches the correspondence between the Accept-Encoding request header, gzip and the resource file. When the resource request is received again subsequently, only when the Accept-Encoding request header is carried in the resource request and the value is gzip, the cache server can respond to the user with the cached resource file. If the resource request does not carry the Accept-Encoding request header, or even if the Accept-Encoding request header is carried but the value is not gzip, the cache server cannot respond to the user with the resource file, and can only pull the resource from the source server.

[0004] However, although the number of request headers is limited, the number of values of request headers is usually infinite. When the cache server caches resource files in the manner that one Vary value corresponds to one resource file, it leads to infinite resource files for the same URL, which requires extremely high storage capacity, has high cost and low hit rate. Therefore, how to cache resource files and quickly respond to users is a problem to be solved. SUMMARY

[0005] Embodiments of the present application provide a resource response method, device and readable storage medium. The resource file of a URL is cached according to a first keyword of the URL, so that the number of resource files of the same URL on the cache server is equal to the number of resource files on the source server at most, and the source server does not need to provide an Etag response header, thereby reducing the requirement for the storage capacity of the cache server and improving the resource file hit rate.

[0006] In a first aspect, embodiments of the present application provide a resource response method applied to a cache server, and the method comprises:

[0007] receiving a request message from a terminal device, the request message being used to request a target resource file;

[0008] determining a first keyword of a target URL according to the request message, the first keyword not containing a query string in the target URL, and the target URL being a URL indicated by the request message;

[0009] determining the target resource file from a resource file set corresponding to the first keyword, the resource file set being used to store a resource file provided by a source station for the target URL;

[0010] sending a response message carrying the target resource file to the terminal device.

[0011] In a second aspect, embodiments of the present application provide an electronic device, which comprises a processor, a memory and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to enable the electronic device to implement the method described in the various possible implementation manners of the first aspect.

[0012] In a third aspect, embodiments of the present application provide a computer readable storage medium, which stores computer instructions, and the computer instructions are used to implement the method described in the various possible implementation manners of the first aspect when executed by a processor.

[0013] In a fourth aspect, embodiments of the present application provide a computer program product comprising a computer program, and the computer program is executed by a processor to implement the method described in the various possible implementation manners of the first aspect.

[0014] The resource response method, device and readable storage medium provided by the embodiments of the present application, after the cache server receives a request message for requesting a target resource file, a primary keyword is determined according to the request message, when the cache server has cached at least one resource file in a resource file set corresponding to the primary keyword, the target resource file is determined from the resource file set, and the target resource file is responded to the terminal device. The resource file set is used to store the resource file provided by the source station for the target URL. By using the scheme, the resource file of the same URL on the cache server is cached according to the primary keyword without the query string, so that the number of resource files of the same URL on the cache server is equal to the number of resource files on the source server at most, and the Etag response header does not need to be provided by the source server, thereby reducing the requirement for the storage capacity of the cache server and improving the resource file hit rate. BRIEF DESCRIPTION OF DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0016] Figure 1A is a network architecture schematic diagram of the resource response method provided by the embodiments of the present application;

[0017] Figure 1B is a schematic diagram of the CDN network architecture to which the resource response method provided by the embodiments of the present application is applicable;

[0018] Figure 2 is a flowchart of the resource response method provided by the embodiments of the present application;

[0019] Figure 3 is a schematic diagram of the resource file cached by using the primary keyword and the secondary keyword in the resource response method provided by the embodiments of the present application;

[0020] Figure 4 is a schematic diagram of a response process of the resource response method provided by the embodiments of the present application;

[0021] Figure 5 is another schematic diagram of a response process of the resource response method provided by the embodiments of the present application;

[0022] Figure 6A is a process schematic diagram of the resource response method provided by the embodiments of the present application;

[0023] Figure 6B is Figure 6A the corresponding flowchart;

[0024] Figure 7 A schematic diagram of a resource response device provided for an embodiment of the present application;

[0025] Figure 8 A structural schematic diagram of an electronic device provided for an embodiment of the present application. DETAILED DESCRIPTION

[0026] At present, an important function of a cache server is to cache a resource file of a URL, so as to facilitate a client accessing the URL to obtain a response more quickly. In an actual scenario, some URLs have a one-to-many relationship with resource files.

[0027] For example, for the same URL, a source server provides two resource files, one for responding to a PC terminal browser and one for responding to a mobile terminal browser.

[0028] For another example, for the same URL, the source server provides different resource files for different compression algorithms, such as a gzip algorithm and a br algorithm.

[0029] For another example, for the same URL, the source server caches different resource files for different regions, such as Asia and Europe.

[0030] For another example, for the same URL, the source server provides different resource files for different users. User information is carried in a Cookie request header.

[0031] Under normal circumstances, the cache server caches resource files by using a "cache negotiation response" method (referred to as a Vary cache mechanism) provided by an HTTP protocol. Based on the mechanism, the source server tells the cache server which request headers to use to cache resource files through a Vary response header in a response message, that is, the cache server caches the correspondence between resource files and values of request headers when caching resource files. When a new message request received by the cache server contains a Vary-specified request header and the value of the request header is the same as the value of the request header of the resource file, the cache server will take the cached resource file as a response to the new request. The value of the Vary-specified request header is also referred to as a Vary value.

[0032] For example, the value of the Accept-Encoding request header of a request message is taken as the Vary value, and it is assumed that the origin server provides two resource files, one of which is compressed in the gzip format and the other of which is an uncompressed resource file. The Vary value is set to gzip. After receiving the request message, the cache server pulls the resource file from the origin server and caches the corresponding relationship between the resource file and the gzip if the resource file is not cached. Subsequently, the cache server can respond to the terminal device with the cached resource file only when the value of the Accept-Encoding request header is gzip. If the request message does not carry the Accept-Encoding request header or carries the Accept-Encoding request header but the value is not gzip, the cache server cannot respond to the terminal device with the resource file but has to pull the resource file from the origin server and cache it. For example, the request message carries the Accept-Encoding request header and the value is br. The cache server pulls the uncompressed resource file from the origin server and caches the corresponding relationship between the uncompressed resource file and the br.

[0033] Subsequently, the cache server receives a request message, and the value of the Accept-Encoding request header of the request message is deflate. The cache server pulls the uncompressed resource file from the origin server and caches the corresponding relationship between the uncompressed resource file and the deflate. Apparently, even though the response to the br algorithm and the deflate algorithm is both the uncompressed resource file, the cache server caches two uncompressed resource files, which is extremely redundant. Apparently, based on the Vary caching mechanism, even if the origin server provides limited resource files, the cache server caches an infinite number of files.

[0034] The advantages of the Vary caching mechanism are as follows: The cache server does not need to be additionally modified and can be executed according to the HTTP protocol specification.

[0035] The disadvantages of the Vary caching mechanism are as follows: The number of values of the request header is usually infinite, resulting in an infinite range of Vary values. If one resource file is cached according to one Vary value, the cache server caches an infinite number of resource files for the same URL, which greatly increases the requirement for storage capacity and reduces the cache hit rate of the cache server.

[0036] To overcome the disadvantages of the Vary caching mechanism, the industry optimizes the cache server as follows:

[0037] When the resource file requested by the terminal device is not cached on the cache server, the cache server performs origin-pulling, i.e., the cache server sends a request message to the source server. The source server sends a response message carrying the resource file to the cache server, and the response message also carries an Etag response header and a value of the Etag response header. The cache server caches the resource file and the value of the corresponding Etag response header, and the cache server subsequently reuses different resource files according to the Etag response header. That is, even if different request messages both carry the request header specified by the Vary, and the values of the request headers are different, but since the value of the Etag response header is the same, the cache server responds to the same resource file.

[0038] For example, the source server only supports the gzip compression mode. When the cache server receives a request message, the value of the Accept-Encoding request header of the request message is gzip, and the cache server does not cache the resource file requested by the request message, the cache server performs origin-pulling, i.e., pulls the resource file from the source server. The cache server receives a response message carrying a resource file 1, and the value of the Etag response header of the response message is a. The resource file 1 is a resource file obtained by using the gizp compression mode. The cache server caches the resource file 1, gzip, and a.

[0039] Subsequently, the cache server receives another request message, the value of the Accept-Encoding request header of the request message is br, and the cache server performs origin-pulling. The cache server receives a response message carrying a resource file 2, and the value of the Etag response header of the response message is b. The resource file 2 is an uncompressed resource file. The cache server caches the resource file 2, br, and b.

[0040] Subsequently, the cache server receives another request message, the value of the Accept-Encoding request header of the request message is br, and the cache server performs origin-pulling. The cache server receives a response message carrying a resource file 2, and the value of the Etag response header of the response message is b. The resource file 2 is an uncompressed resource file. The cache server caches the resource file 2, br, and b.

[0041] After that, if the cache server continues to receive the request message, the value of the Accept-Encoding request header of the request message is br or Wzip, the cache server responds to the terminal device with the locally cached resource file 2.

[0042] Obviously, after the above optimization, even if two different request messages both carry the request header specified by Vary, and the values of the request headers are different, but since the value of the Etag response header is the same, the cache server responds to the same resource file. At the same time, the number of resource files of the same URL on the cache server is equal to the number of resource files of the URL on the source server.

[0043] However, the premise of the above optimization method is that the source server must provide the Etag response header. However, not all source servers will provide the Etag response header.

[0044] According to the above, the source server cannot prepare a resource file for each value of the request header, but can only prepare a limited number of resource files. When the source server does not provide the Etag response header, or the cache server is not optimized for the Vary caching mechanism, the number of resource files cached by the cache server is very large, making the cache server and the source server vulnerable to malicious attacks. Taking the value of the User-Agent request header as an example, the attacker forges a large number of values of the User-Agent request header, and different request messages carry different values of the User-Agent request header, so that the cache server consumes a large amount of storage resources, and the hit rate of the cache server is 0. Moreover, each time the cache server receives a request message, since the Vary value is different, it will pull resources from the source server, which will bring great pressure to the source server.

[0045] Squid cache server and Nginx cache server are two common cache servers supporting Vary caching mechanism. Squid cache server usually uses Vary caching mechanism to cache resource files, and takes request method + request protocol + URL + Vary value as the cache key of cached resources. Since the key includes the Vary value, and the value range of the Vary value is infinite, it leads to high requirement for the storage capacity of the Squid server, and also leads to poor hit rate.

[0046] Nginx server uses variable free splicing to generate cache key, and has built-in Vary caching mechanism, that is, it does not need to put Vary request header in the cache key. This kind of caching mechanism is very flexible and has strong extensibility. However, excessive flexibility may lead to unreasonable configuration, resulting in cache errors. For example, if a string that does not contain variables is used as a cache key, all URLs will correspond to the same resource file.

[0047] Based on this, the embodiment of the present application provides a resource response method, device and readable storage medium, by caching the resource file of the URL according to the first keyword of the URL, so that the number of resource files of the same URL on the cache server is equal to the number of resource files on the source server at most, and the Etag response header does not need to be provided by the source server, the requirement for the storage capacity of the cache server is reduced and the resource file hit rate is improved.

[0048] Figure 1A The network architecture of the resource response method provided by the embodiment of the present application is shown in the figure. Please refer to Figure 1A The network architecture includes a cache server 11, a source server 12 and a terminal device 13, a network connection is established between the cache server 11 and the source server 12, and a network connection is established between the cache server 11 and the terminal device 13.

[0049] The cache server 11 caches the resource file pulled from the source server 12. When the cache server 11 receives a request message from the terminal device 13, if the resource file requested by the request message has been cached locally, the cache server responds to the terminal device 13 with the local resource file. If the cache server 11 does not cache the resource file requested by the request message locally, the resource file is pulled from the source server 12 and cached, so that when the same resource file is requested again in the future, the resource file does not need to be pulled from the source server 12.

[0050] The cache server 11 is, for example, an edge node in a content delivery network (CDN), and the cache server 11 can be hardware or software. When the cache server 11 is hardware, it is a single server or a distributed server cluster composed of multiple servers. When the cache server 11 is software, it can be multiple software modules or a single software module, etc., which is not limited by the embodiment of the present application.

[0051] The source server 12 is a superior server of the cache server 11. The source server 12 can be hardware or software. When the server 12 is hardware, the server 12 is a single server or a distributed server cluster composed of multiple servers. When the server 12 is software, it can be multiple software modules or a single software module, etc., which is not limited by the embodiment of the present application.

[0052] The terminal device 13 can be hardware or software. When the terminal device 13 is hardware, it is, for example, a mobile phone, a tablet computer, an e-book reader, a laptop computer, a desktop computer, a server, etc. When the terminal device 13 is software, it can be installed in the above-mentioned hardware devices, at this time, the terminal device 13 is, for example, multiple software modules or a single software module, etc., which is not limited by the embodiment of the present application.

[0053] It should be understood that, Figure 1A The number of cache servers 11, source servers 12 and terminal devices 13 in the CDN network shown in FIG. 1 is only illustrative. In actual implementation, any number of cache servers 11, source servers 12 and terminal devices 13 can be deployed according to actual needs.

[0054] In addition, the CDN network includes multiple levels of cache nodes. In different scenarios, the same cache node can be used as the cache server 11 or the source server 12. For example, please refer to Figure 1B , Figure 1B is a schematic diagram of the architecture of the CDN network to which the resource response method provided by the embodiments of the present application is applicable.

[0055] Please refer to Figure 1B , the CDN network includes multiple levels of cache nodes, such as upper nodes 14, middle nodes 15 and edge nodes 16. The upper nodes 14 are directly connected to the source station 17, and the middle nodes 15 are connected to the upper nodes 14 and the edge nodes 16. The resource response method provided by the embodiments of the present application can be applied to any level of cache node. That is, the cache server 11 in the embodiments of the present application can be any level of cache node. The edge node 16 is used to receive a request message from a terminal device.

[0056] For example, when the cache server 11 is the edge node 16, the source server 12 is the middle node 15; when the cache server 11 is the middle node 15, the source server 12 is the upper node 14; when the cache server 11 is the upper node 14, the source server 12 is the source station 17. In summary, when the current level of cache node receives a message request from a lower level of cache node or a terminal device, if the local cache does not cache the resource file requested by the message request, the resource file is pulled from the upper level of node. The resource response method provided by the embodiments of the present application can be applied to any level of cache node.

[0057] Next, based on the network architecture shown in Figure 1A and Figure 1B , the resource response method provided by the embodiments of the present application will be described in detail. For example, please refer to Figure 2 .

[0058] Figure 2 is a flowchart of the resource response method provided by the embodiments of the present application. The embodiment is described from the perspective of the cache server. The embodiment includes:

[0059] 201, receiving a request message from a terminal device, the request message being used to request a target resource file.

[0060] In the embodiments of the present application, the resource files include videos, audios, pictures, web pages, etc., and the request message is, for example, a HyperText Transfer Protocol (HTTP) request message or a HyperText Transfer Protocol Secure (HTTPS) request message.

[0061] For details, please refer to Figure 1B When the cache server is an edge node, the cache server receives the message request from the terminal device. In addition, when the cache server is a middle node, the cache server receives the message request from the edge node; when the cache server is an upper node, the cache server receives the message request from the middle node.

[0062] 202. Determine a first keyword of the target URL according to the request message, wherein the first keyword does not contain a query string in the target URL, and the target URL is a URL indicated by the request message.

[0063] In the embodiments of the present application, for each URL, the cache server caches the resource file corresponding to the URL, and one URL can correspond to one or more resource files. The URL determined by the cache server according to the request message is referred to as a target URL.

[0064] When the target URL is a continuous string in the request message, the cache server extracts the string from the request message and takes the string as the target URL. When the target URL is a combination of scattered strings in the request message, the cache server extracts each string and splices the strings to obtain the target URL.

[0065] For example, the cache server provides a cache function and is also a forward proxy server. The request line and the Host request header of the request message are as follows:

[0066] GET https: / / xxxx.com / item / 5937042?fromtitle=URL&fromid=110640&fr=aladdin HTTP / 1.1

[0067] Host:xxx.com

[0068] The URL in the request message is a complete string https: / / xxxx.com / item / 5937042?fromtitle=URL&fromid=110640&fr=aladdin HTTP / 1.1, and therefore, the cache server extracts the complete string as the target URL.

[0069] According to the request message, the request method is GET, and a complete URL, i.e., https: / / xxxx.com / item / 5937042?fromtitle=URL&fromid=110640&fr=aladdin, is after the GET, and a protocol version is after the URL. The value of the Host request header of the request message is a domain name, which is the same as the domain name of the URL in the request message.

[0070] However, the embodiments of the present application are not limited, and in other possible implementation manners, if the request line has a complete URL, the cache server extracts the URL from the request line as the target URL, regardless of whether the request message includes the Host request header, and whether the value of the Host request header is the same as the domain name of the URL in the request line.

[0071] For another example, the cache server does not provide a forward proxy function, and the request line and the Host request header of the received request message are as follows:

[0072] GET / item / 5937042?fromtitle=URL&fromid=110640&fr=aladdin HTTP / 1.1

[0073] Host:xxx.com

[0074] In the request message, the URL in the request line is not complete, the cache server extracts the following string from the request line: / item / 5937042?fromtitle=URL&fromid=110640&fr=aladdin, and extracts the value xxx.com of the Host request header, and splices the two strings to obtain the target URL: https: / / xxxx.com / item / 5937042?fromtitle=URL&fromid=110640&fr=aladdin.

[0075] In the embodiments of the present application, since the resource file set is used to store the resource files provided by the source station for the target URL, the number of resource files in the resource file set is at most the number of resource files provided by the source station for the target URL, and the number of resource files in the resource file set itself has differences, such as different compression modes, different corresponding browsers, and the like.

[0076] The primary keyword is also called the main key. If the cache server determines the primary keyword by only considering the target URL, the primary keyword and the target URL are in one-to-one correspondence. If the cache server determines the primary keyword by combining the target URL and the request method, the target URL and the primary keyword are in one-to-many correspondence, and the number of primary keywords is at most equal to the number of request methods. After the cache server pulls the resource file from the source server each time, the cache server stores the resource file in the resource file set corresponding to the primary keyword.

[0077] The cache server determines the primary keyword according to the protocol type, domain name, resource name, and the like in the target URL. When the target URL contains a query string, the primary keyword does not contain the query string in the target URL. The query string is a differentiated parameter under the same URL, that is, in the embodiments of the present application, the differentiated parameter under the same URL cannot be reflected in the primary keyword, and in some traditional cache solutions, the cache server stores the resource file by taking the URL and the differentiated parameter under the same URL as the key when caching the resource file, so that the number of resource files cached by the cache server is infinite.

[0078] Continuing with the above example, the cache server determines the primary keyword as GET https: / / xxxx.com / item / 5937042 according to the target URL and the request method. The primary keyword does not contain the query string in the target URL.

[0079] 203. Determine the target resource file from the resource file set corresponding to the primary keyword, and the resource file set is used to store the resource file provided by the source station for the target URL.

[0080] After the cache server determines the primary keyword, the cache server determines the resource file set corresponding to the primary keyword about the target URL from the resource files cached by the cache server, and determines the target resource file from the resource file set. For example, if the target URL has only one primary keyword, the source server prepares only one resource file for the primary keyword, and the cache server has cached the resource file before receiving the request message this time, the cache server takes the resource file as the target resource file. If the target URL has multiple primary keywords, the cache server determines the primary keyword according to the request message, and determines the target resource file from the resource file set corresponding to the primary keyword,

[0081] 204. Send a response message carrying the target resource file to the terminal device.

[0082] After identifying the target resource file, the cache server generates a response message carrying the target resource file and sends it to the terminal device. Additionally, if the cache server is as described above... Figure 1B The middle-level cache nodes send a response message carrying the target resource file to the edge cache nodes; if the cache server is one of the above... Figure 1B The upper-level cache node sends a response message carrying the target resource file to the middle-level cache node.

[0083] The resource response method provided in this application involves a caching server receiving a request message for a target resource file. The server determines a primary keyword based on the request message. If the caching server has already cached at least one resource file from the resource file set corresponding to the primary keyword, it determines the target resource file from the resource file set and sends the target resource file to the terminal device. The resource file set stores the resource files provided by the origin server for the target URL. This approach, by caching resource files for a URL based on a primary keyword that does not contain a query string, ensures that the number of resource files for the same URL on the caching server is at most equal to the number of resource files on the origin server. Furthermore, it eliminates the need for the origin server to provide an ETag response header, reducing the storage capacity requirements of the caching server and improving the resource file hit rate.

[0084] Optionally, in the above embodiments, during the process of determining the primary keyword based on the request message, the caching server determines the target URL based on the request message, and then determines whether the target URL carries a question mark. If the target URL carries a question mark, the caching server determines the valid fields from the target URL, and determines the primary keyword based on the valid fields and the request method indicated by the request message. The valid fields include the characters preceding the question mark in the target URL.

[0085] For example, the target URL is: https: / / xxxx.com / item / 5937042?fromtitle=URL&fromid=110640&fr=aladdin.

[0086] The target URL contains a question mark (?), therefore, the caching server extracts the valid field from the target URL: https: / / xxxx.com / item / 5937042. Then, the caching server generates a primary keyword based on the request method and valid field in the request message. Assuming the request method is GET, the primary keyword is GET https: / / xxxx.com / item / 5937042; assuming the request method is HEAD, the primary keyword is HEAD https: / / xxxx.com / item / 5937042.

[0087] When the target URL does not carry a question mark, the cache server determines the primary keyword according to the target URL and the request method indicated in the request message.

[0088] For example, the target URL is https: / / xxxx.com / item / 5937042. The target URL does not contain a question mark. Therefore, the cache server generates a primary keyword according to the request method in the request message and the target URL. Assuming that the request method is GET, the primary keyword is GET https: / / xxxx.com / item / 5937042; assuming that the request method is HEAD, the primary keyword is HEAD https: / / xxxx.com / item / 5937042.

[0089] It should be noted that in the embodiments of the present application, after the cache server determines the primary keyword, the value of the primary keyword is the initial value. If not specially stated, the determination of the resource file set according to the primary keyword refers to the determination of the resource file set according to the initial value of the primary keyword.

[0090] With this scheme, the cache server generates a primary keyword according to the request method and the target URL without a question mark, or the cache server generates a primary keyword according to the request method and the effective field in the target URL with a question mark, which is fast and accurate.

[0091] Optionally, in the above embodiments, in the process in which the cache server determines the target resource file from the resource file set corresponding to the primary keyword, first, a secondary keyword is determined according to the additional parameters in the request message. Different secondary keywords of the same URL correspond to different resource files. Then, the target resource file is determined from the resource file set according to the secondary keyword.

[0092] In the embodiments of the present application, the target URL can correspond to one or more first-level keywords. For example, each different request method and the same target URL form a different first-level keyword, and each first-level keyword corresponds to a resource file set containing one or more resource files. The cache server determines the first-level keyword of the target URL according to the request message. When the target URL has only one resource file, the cache server caches the resource file only by using the first-level keyword. At this time, the resource file set corresponding to the first-level keyword has only one resource file. The configuration file loaded in advance by the cache server indicates that there is only one resource file under the first-level keyword, and there is no need to query the second-level keyword. Therefore, when the cache server subsequently receives a request message, the target URL is determined according to the request message, and then the first-level keyword is determined. The only resource file in the resource file set of the first-level keyword is responded to the terminal device. For example, the target resource file is an image, and the image has a first-level keyword. Regardless of the compression algorithm indicated by the Accept-Encoding request header in the request message or the region where the terminal device initiating the request message is located, the cache server does not distinguish the compression algorithm, the region, and the like, and responds the image to the terminal device.

[0093] When the resource file set corresponding to the first-level keyword has multiple resource files, the cache server determines the resource file set according to the first-level keyword, and further determines the second-level keyword. The target resource file is determined from the resource file set according to the second-level keyword. For example, the cache server determines the second-level keyword according to the differentiated parameter under the same target URL. The differentiated parameter is often a variable. The variable includes but is not limited to the query string in the target URL, the request protocol version in the request message, and the like, which are not limited in the embodiments of the present application. The cache server uses a regular expression to match a certain type of variable, maps the variable to a fixed value, and the fixed value is the second-level keyword.

[0094] Figure 3 FIG. 1 is a schematic diagram of caching resource files by using first-level keywords and second-level keywords in the resource response method provided by the embodiments of the present application. Please refer to Figure 3 For the target URL, the cache server determines the first-level keyword according to the target URL and the request method in the request message, and the first-level keyword corresponds to a resource file set. Each resource file in the resource file set has a second-level keyword, which is determined by the cache server according to the additional parameter.

[0095] For example, the value of the additional parameter is the value of the Accept-Encoding request header, the cache server receives N request messages for accessing the same URL, i.e., the target URL, and the values of the Accept-Encoding request header are additional parameter 1 (such as Gzip), additional parameter 2 (such as Wzip), and additional parameter N (such as other), respectively. The cache server determines the secondary keywords corresponding to the additional parameters, and if the secondary keyword corresponding resource files are not cached locally, the cache server pulls and caches the resource files from the source server. During the caching process, the resource files have the same primary keyword but different secondary keywords. For example, Figure 3 In the example, resource file 1 corresponds to secondary keyword 1, resource file 2 corresponds to secondary keyword 2, and resource file N corresponds to secondary keyword N, and the secondary keywords correspond to the same primary keyword.

[0096] Therefore, after the cache server receives a request message and determines the primary keyword, the cache server can determine the resource file set containing multiple resource files. Then, the cache server reads the configuration file and finds that the secondary keyword needs to be further determined according to the additional parameter. Then, the cache server further determines the secondary keyword and determines the target resource file from the resource file set.

[0097] For example, for a certain URL, the source server prepares two resource files, i.e., a resource file supporting the gzip compression mode and a resource file supporting the br compression mode. The secondary keywords of the two resource files are gzip and br, respectively, and the primary keyword is determined according to the target URL and the request method. The configuration file preloaded on the cache server indicates that the additional parameter for determining the secondary keyword is the value of the Accept-Encoding request header. Then, the cache server determines the value of the Accept-Encoding request header according to the request message each time the cache server receives the request message. If the value of the Accept-Encoding request header is gzip, the cache server determines the resource file supporting the gizp compression mode from the resource file set according to the secondary keyword gzip. If the value of the Accept-Encoding request header is br, the cache server determines the secondary keyword as br, and the cache server determines the resource file supporting the br compression mode from the resource file set according to the secondary keyword br.

[0098] In the embodiment of the application, when the cache server caches resource files in the structure of the primary keyword + the secondary keyword, if it is necessary to delete or update the resource files in the resource file set corresponding to the primary keyword, the resource file set can be quickly found through the primary keyword, and all resource files in the resource file set can be conveniently deleted or updated.

[0099] When the source server updates the resource file set corresponding to the URL, the cache server also needs to update the corresponding resource file set. The operation and maintenance personnel of the source server sends a change instruction to all cache servers through an operation and maintenance terminal. After each cache server receives the change instruction, if the change instruction indicates to update the resource file set, each cache server determines the first-level keyword according to the change instruction, finds the resource file set by using the first-level keyword, and updates the resource files supporting the gzip compression mode and the resource files supporting the br compression mode in the resource file set.

[0100] By using the scheme, the resource files are cached by using the two-level keyword structure, so that the first-level keyword corresponds to multiple resource files, and different second-level keywords correspond to different resource files, thereby facilitating quick deletion or update of all resource files in the resource file set.

[0101] Optionally, in the above embodiment, when the cache server determines the second-level keyword according to the additional parameter in the request message, the cache server queries a matching table according to the additional parameter to determine the second-level keyword. The additional parameter includes at least one of the following parameters: a request protocol version, a value of a request header, a query string in a URL, and the like. The request protocol version is, for example, HTTP / 1.0, HTTP1.1, HTTP / 2, HTTP / 3, and the like.

[0102] For example, the cache server pre-stores a configured matching table, which indicates the correspondence between the additional parameter and the second-level keyword. For example, the additional parameter is the value of the User-Agent request header in the request message, the source server provides different resource files for three kinds of browsers, and another cache file is used for other browsers. The matching relationship is shown in Table 1:

[0103] Table 1

[0104]

[0105]

[0106] Referring to Table 1, for a certain URL, the source server prepares four resource files corresponding to the IE browser, the Firefox browser, the Chrome browser, and other browsers. The second-level keywords of the four resource files are ie, firefox, chrome, and other, respectively. The first-level keyword is determined according to the target URL and the request method.

[0107] The cache server receives the request message, determines a first key according to the request message, determines a resource file set corresponding to the first key according to a local configuration file, and caches each resource file through the structure of the first key and a second key. The second key is determined according to the value of the User-Agent request header, and the value of the User-Agent request header can be regarded as an initial value of the second key. Therefore, the cache server determines the resource file set according to the first key. Then, if a matching table is configured, the cache server can determine a matching value by querying the matching table according to the value of the User-Agent request header, and then determine a target resource file from the file set according to the matching value. In the matching process, if the value of the User-Agent request header matches a matching rule, the matching rule is a corresponding relationship between the initial value of the second key and the matching value; if the value of the User-Agent request header does not exist in the matching table, the value of the User-Agent request header is matched with an empty string, and the second key is determined according to the empty string, as shown in the last column of Table 1.

[0108] For example, the value of the User-Agent request header is IE6.0, and the matching value is determined as ie by querying the matching table. Therefore, the cache server takes the resource file with the second key ie in the resource file set of the target URL as the target resource file and responds to the terminal device.

[0109] For another example, the value of the User-Agent request header in the request message is Edge10.0, and the matching value is determined as other by querying the matching table. Therefore, the cache server takes the resource file with the second key other in the resource file set of the target URL as the target resource file and responds to the terminal device.

[0110] According to the matching rule shown in Table 1, the value of the User-Agent request header can be converged into four values, and the mapped value is taken as the second key. In this way, at most four resource files will be cached on the cache server for the target URL.

[0111] Table 1 above takes the value of the User-Agent request header as an example to illustrate how to remove redundant cache files. Next, the value of the Accept-Encoding request header is taken as an example to illustrate how to remove redundant cache files.

[0112] For example, for a certain URL, the origin server prepares two resource files, one supporting gzip compression and the other uncompressed. The secondary keywords of the two resource files are gzip and other respectively (in practice, they can also be non-compressed, none, etc., and the embodiments of the present application do not limit this), and the primary keyword is determined according to the target URL and the request method.

[0113] After the cache server receives the request message and extracts the value of the Accept-Encoding request header, if the value of the Accept-Encoding request header is gzip, the cache server determines the resource file supporting the gizp compression from the resource file set according to the secondary keyword gzip. In this embodiment, the initial value is gzip, and the mapping value is gzip, that is, the initial value = gzip, and one mapping value corresponds to one initial value.

[0114] If the value of the Accept-Encoding request header is br, the cache server determines that the secondary keyword is other, and determines the uncompressed resource file from the resource file set.

[0115] Similarly, if the value of the Accept-Encoding request header is xxx1, xxx2, etc., the cache server determines that the secondary keyword is other, and determines the uncompressed resource file from the resource file set. Wherein, xxx1, xxx2, etc. represent maliciously constructed values of the Accept-Encoding request header. When the value of the Accept-Encoding request header is other than gzip, that is, the initial value is other than gzip, the mapping value is other, that is, one mapping value corresponds to at least two initial values.

[0116] Obviously, only when the value of the Accept-Encoding request header is gzip, the cache server determines the resource file supporting the gizp compression from the resource file set. When the value of the Accept-Encoding request header is a maliciously constructed request header value or a request header value not supported by the origin server, the secondary keyword determined by the cache server according to the request header is other, and the cache server will not cache different resource files for each different request header value, greatly reducing redundant cache files and improving hit efficiency.

[0117] With this scheme, the values of the unlimited additional parameters are mapped to a limited number of secondary keywords in an additional parameter mapping manner, a large amount of redundant information in the additional parameters is removed, the number of resource files cached on the cache server is effectively reduced, the cache hit rate of the cache server is improved, and the operation of pulling resource files from the cache server to the origin server is reduced.

[0118] Optionally, in the above embodiment, when the target resource file is not cached in the resource file set or the cache server does not cache the resource file set, the cache server sends the request message to the source server. Then, the cache server receives a source response message from the source server, the source response message carrying the target resource file, the correspondence between the target resource file and the primary keyword, and the correspondence between the target resource file and the secondary keyword. After that, the cache server caches the target resource file, the correspondence between the target resource file and the primary keyword, and the correspondence between the target resource file and the secondary keyword.

[0119] For example, the target URL corresponds to multiple resource files, i.e., the source station prepares multiple resource files for the target URL. After the cache server receives the request message from the subordinate node or the terminal device each time, the cache server determines the target URL according to the request message. Then, the cache server reads the local configuration file and finds that, for the target URL, the resource file needs to be cached in the structure of the primary keyword + the secondary keyword, and the secondary keyword is determined according to the additional parameter (assuming that the additional parameter is User-Agent). Therefore, the cache server further determines the primary keyword according to the target URL. If the cache server does not cache any resource file corresponding to the target URL, i.e., the resource file set is empty, the cache server sends the request message to the source server.

[0120] When the cache server receives the source response message, the cache server extracts the target resource file from the source response message. Then, the cache server caches the target resource file in the structure of the primary keyword + the secondary keyword, and responds to the terminal device with the target resource file. Assuming that the primary keyword is HEAD https: / / xxxx.com / item / 5937042, the additional parameter is the User-Agent request header, and the value of the User-Agent request header is ie6.0, the cache server caches one resource file of the target URL in the structure of the primary keyword + the secondary keyword. The primary keyword is HEAD https: / / xxxx.com / item / 5937042, and the secondary keyword is ie.

[0121] When the cache server receives the request message again, if the primary keyword is HEAD https: / / xxxx.com / item / 5937042, the additional parameter is the User-Agent request header, and the secondary keyword is determined to be ie according to the value of the User-Agent request header, the cache server responds to the terminal device with the cached resource file as the target resource file.

[0122] If the first keyword is HEAD https: / / xxxx.com / item / 5937042, the additional parameter is the User-Agent request header, and the second keyword is determined to be firefox according to the value of the User-Agent request header, the cache server pulls the resource file from the source server, and after the resource file is pulled, the cache server caches the corresponding relationship between the resource file, the first keyword HEAD https: / / xxxx.com / item / 5937042, and the second keyword firefox.

[0123] In this scheme, the cache server determines whether the target resource file exists in the local cache according to the order of the first keyword and the second keyword. If the target resource file does not exist in the local cache, the cache server pulls the resource file from the source server, thereby improving the resource response success rate.

[0124] Optionally, in the above embodiment, the cache server further receives a change instruction, and the change instruction is used to indicate deleting or updating the resource file set corresponding to the target URL. Then, the cache server deletes or updates the resource file set corresponding to the target URL.

[0125] For example, when the resource file set on the source server is updated or expired, because the number of cache servers in the network is large, the operation and maintenance personnel of the source server do not know which cache server caches the resource file of the target URL. Therefore, the operation and maintenance personnel sends a change instruction to each cache server through an operation and maintenance terminal, and the change instruction carries the target URL or the first keyword of the target URL. After receiving the change instruction indicating deleting the resource file, if the cache server caches the resource file set, the cache server deletes the resource file set. If the cache server does not cache the resource file set, the cache server discards the change instruction. After receiving the change instruction indicating updating the resource file, if the cache server caches the resource file set, the cache server updates the resource file in the resource file set. If the cache server does not cache the resource file set, the cache server discards the change instruction.

[0126] In this scheme, the cache server caches the resource file in the structure of the first keyword + the second keyword. Because there are multiple resource files under the first keyword, when receiving the change instruction, the cache server can quickly delete or update the resource file set, thereby improving the response speed.

[0127] Figure 4 is a response process schematic diagram of a resource response method provided by an embodiment of the present application. Please refer to Figure 4 , the request message initiated by the client, and part of the information of the request message is as follows:

[0128] GET / web.htm?arg1=1HTTP / 1.1

[0129] Host:cache.com

[0130] User-Agent:IE6.0

[0131] According to the request line of the request message, it can be known that the request method is GET, the name of the target resource file is web.htm, the protocol is http, and the query string is arg=1; the value of the Host request header is cache.com, and the value of the User-Agent request header is IE6.0.

[0132] The cache server determines that the target URL is http: / / cache.com / web.htm?arg1=1 according to the request message. Since the target URL carries a question mark and the request method is GET, the cache server determines that the first-level keyword is:

[0133] GET http: / / cache.com / web.htm

[0134] According to the first-level keyword, the cache server determines the resource file set of the target URL, which includes three resource files, namely, resource file 1 corresponding to the IE browser, resource file 2 corresponding to the chrome browser, and resource file 3 corresponding to other browsers. That is, the source server has prepared 3 resource files for the target URL, and the cache server has cached the three resource files before receiving the request message this time.

[0135] The cache server finds that the matching table of the target URL is stored in the local in advance, as shown in Table 3:

[0136] Table 3

[0137] Regular expression matching Maps to ^IE.* ie ^Chrome.* chrome .* other

[0138] Since the value of the User-Agent request header is IE6.0, the second-level keyword is obtained by querying the matching table, that is, ie, and the cache server determines that the target resource file is resource file 1.

[0139] It should be noted that the structure of the first-level keyword+second-level keyword in the embodiment of the application is optional. For example, a certain URL has only one resource file, and the cache server only caches the first-level keyword and the resource file, without any second-level resource file.

[0140] In the embodiment of the present application, the default cache server caches resource files according to the initial value of the first keyword. If there is a second keyword, the default cache server caches resource files according to the structure of the first keyword + the second keyword. After receiving a request message, the default cache server determines a target resource file set according to the initial value of the first keyword, and then determines the target resource file from the target resource file set according to the second keyword. This method of caching and querying resource files according to the initial value of the first keyword is referred to as a default rule. According to the default rule, different initial values of the first keyword correspond to different target resource file sets.

[0141] However, the embodiment of the present application is not limited thereto. In other optional implementations, different first keywords can share resource files, thereby further reducing the number of resource files on the cache server.

[0142] After receiving a request message, the cache server determines a target URL according to the request message, and then determines the initial value of the first keyword. Then, the cache server determines whether a mapping rule exists locally. The mapping rule is used to indicate the corresponding relationship between the initial value of the first keyword and a mapping value. When the mapping rule is not configured on the cache server, the cache server determines a target resource file set according to the initial value of the first keyword, and then determines the target resource file from the target resource file set. When the mapping rule of the first keyword is configured on the cache server, the cache server determines a mapping value of the first keyword according to the initial value of the first keyword, and then determines a target resource file set according to the mapping value of the first keyword, and then determines the target resource file from the target resource file set.

[0143] For example, if the mapping rule is not configured on the cache server, the cache server uses the default rule, that is, caches and queries resource files according to the initial value of the first keyword. In this way, different initial values of the first keyword correspond to different target resource file sets, thereby achieving the purpose of quickly determining the target resource file.

[0144] If the mapping rule of the first keyword is configured on the cache server, the cache server queries the mapping rule according to the initial value of the first keyword, determines a mapping value of the first keyword, and then determines a target resource file according to the mapping value of the first keyword. For example, refer to Table 2. Table 2 shows the mapping relationship between the initial value and the mapping value of the first keyword in the resource response method provided by the embodiment of the present application.

[0145] Table 2

[0146] Initial value for primary keyword Mapped value for primary keyword GET http: / / cache.+\.com / web.+\.htm GET http: / / cache.com / web.htm

[0147] Referring to Table 2, if the domain name in the initial value of the first-level keyword contains cache and the resource name contains web, the mapping value of the first-level keyword is GET http: / / cache.com / web.htm. For example, if the initial value of the first-level keyword is GET http: / / cache1.com / web1.htm, the mapping value is GET http: / / cache.com / web.htm. For another example, if the initial value of the first-level keyword is GET http: / / cache2.com / web2.htm, the mapping value is GET http: / / cache.com / web.htm.

[0148] After receiving the request message, the cache server determines the target URL according to the request message, and determines the initial value of the first-level keyword according to the target URL. Then, the cache server queries the mapping table to determine the mapping value of the first-level keyword. If the second-level keyword is also configured, the cache server determines the resource file set according to the mapping value of the first-level keyword, and then determines the target resource file from the resource file set according to the second-level keyword. If the resource file set corresponding to the mapping value of the first-level keyword is not cached locally, or the target resource file does not exist in the resource file set, the cache server performs a back-to-source operation to pull the target resource file.

[0149] It should be noted that although the sharing of resource files by different first-level keywords modifies the resource name, such as modifying the resource name web1.htm to web.htm and the resource name web2.htm to web.htm in Table 2, the default first-level keyword contains the "request method" and URL, which greatly reduces the probability of errors made by operators.

[0150] By using this scheme, different first-level keywords, i.e., different URLs, share the same resource file, which further reduces the number of resource files on the cache server and reduces the consumption of storage resources.

[0151] Figure 5 is another response process diagram of the resource response method provided by the embodiment of the present application. Referring to Figure 5 , the request message initiated by the client 1, part of the information of the request message is as follows:

[0152] GET / web1.htm?arg1=1HTTP / 1.1

[0153] Host:cache1.com

[0154] User-Agent:IE6.0

[0155] According to the request line of the request message, it is known that the request method is GET, the name of the target resource file is web1.htm, the protocol is http, and the query string is arg1=1; the value of the Host request header is cache1.com, and the value of the User-Agent request header is IE6.0.

[0156] The cache server determines that the target URL is http: / / cache1.com / web1.htm?arg=1 according to the request message. Since the target URL carries a?, and the request method is GET, the cache server determines that the first-level keyword is GET http: / / cache1.com / web1.htm.

[0157] The cache server reads the local configuration and finds that the mapping rule of the first-level keyword has been pre-configured for the target URL, but the matching table of the second-level keyword has not been configured. Therefore, the cache server queries the mapping rule according to the initial value of the first-level keyword to determine the mapping value. For example, refer to Table 2 above.

[0158] Refer to Table 2, the cache server determines that if the initial value of the first-level keyword is GET http: / / cache.+\.com / web.+\.htm, the mapping value is GET http: / / cache.com / web.htm. If the resource file corresponding to the mapping value has been cached locally, the resource file is responded to the terminal device. If the resource file corresponding to the mapping value has not been cached locally, the resource file is pulled up by back-to-source.

[0159] Please continue to refer to Figure 5 , the request message initiated by the client 2, part of the information of the request message is as follows:

[0160] GET / web2.htm HTTP / 1.1

[0161] Host:cache2.com

[0162] User-Agent:IE6.0

[0163] According to the request line of the request message, it is known that the request method is GET, the name of the target resource file is web2.htm, the protocol is http; the value of the Host request header is cache2.com, and the value of the User-Agent request header is IE6.0.

[0164] The cache server determines that the target URL is http: / / cache2.com / web1.htm according to the request message. Since the target URL does not carry a "?" and the request method is GET, the cache server determines that the initial value of the first-level keyword is GET http: / / cache2.com / web2.htm.

[0165] The cache server reads the local mapping rule and finds that the mapping rule of the first-level keyword is pre-configured for the target URL. Therefore, the cache server does not use the default method of determining the resource file set according to the initial value of the first-level keyword, but queries the mapping rule according to the initial value of the first-level keyword to determine the mapping value. For example, refer to Table 2 above.

[0166] Refer to Table 2, the cache server determines that the mapping value is GET http: / / cache.com / web.htm. If the resource file corresponding to the mapping value is cached locally, the resource file is responded to the terminal device. If the resource file corresponding to the mapping value is not cached locally, the resource file is pulled by back-to-source.

[0167] According to Figure 5 It can be seen that different first-level keywords share resource files, further reducing the number of resource files cached by the cache server and reducing the consumption of storage resources.

[0168] Figure 6A is a process diagram of the resource response method provided by the embodiment of the application, Figure 6B is Figure 6A the corresponding flowchart. Refer to Figure 6A and Figure 6B , the embodiment includes:

[0169] 601, the cache server receives a request message from a terminal device.

[0170] 602, the cache server determines a target URL according to the request message, and determines a first-level keyword according to the request method and the target URL.

[0171] 603, the cache server determines whether the mapping rule corresponding to the first-level keyword is configured, if the mapping rule is not configured, step 604 is performed; if the mapping rule is pre-configured, step 605 is performed.

[0172] 604, the cache server takes the initial value of the first-level keyword as the final value, and then performs step 606.

[0173] 605, the cache server queries the mapping rule according to the initial value of the first-level keyword to determine the mapping value of the first-level keyword, and takes the mapping value of the first-level keyword as the final value, and then performs step 606.

[0174] 606、The cache server reads the configuration file to determine whether the secondary keyword needs to be calculated, if the secondary keyword needs to be calculated, step 607 is performed; if the secondary keyword does not need to be calculated, step 612 is performed.

[0175] 607、The cache server determines the initial value of the secondary keyword according to the additional parameter.

[0176] For example, the cache server determines the initial value of the secondary keyword according to the value of the additional parameter, etc. For example, the cache server directly takes the value of the additional parameter as the secondary keyword.

[0177] 608、The cache server determines whether the matching table needs to be queried to determine the matching value of the secondary keyword. If the matching value of the secondary keyword needs to be determined, step 609 is performed; if the matching value of the secondary keyword does not need to be determined, step 610 is performed.

[0178] 609、The cache server queries the matching table to determine the matching value of the secondary keyword, and takes the matching value as the final value of the secondary keyword.

[0179] The matching table is shown in Table 1 above.

[0180] 610、The cache server takes the initial value of the secondary keyword as the final value of the secondary keyword.

[0181] 611、The cache server determines the resource file set according to the final value of the primary keyword, and then determines the target resource file from the resource file set according to the final value of the secondary keyword.

[0182] 612、The cache server determines the target resource file according to the final value of the primary keyword.

[0183] The following is an embodiment of the device of the present application, which can be used to execute the method embodiment of the present application. For details not disclosed in the device embodiment of the present application, please refer to the method embodiment of the present application.

[0184] Figure 7 A schematic diagram of a resource response device according to an embodiment of the present application is shown in FIG. 7. The resource response device 700 includes a receiving module 71, a determining module 72, a processing module 73, and a sending module 74.

[0185] The receiving module 71 is configured to receive a request message from a terminal device, wherein the request message is used to request a target resource file.

[0186] The determining module 72 is configured to determine a primary keyword of a target URL according to the request message, wherein the primary keyword does not contain a query string in the target URL, and the target URL is a URL indicated by the request message.

[0187] determine the target resource file from the resource file set corresponding to the primary keyword, the resource file set being used to store a resource file provided by a source station for the target URL;

[0188] send a response message carrying the target resource file to the terminal device.

[0189] In a possible implementation, when the processing module 73 determines the target resource file from the resource file set, the processing module 73 is configured to determine a secondary keyword according to an additional parameter in the request message, different secondary keywords corresponding to different resource files of the same URL; and determine the target resource file from the resource file set according to the secondary keyword.

[0190] In a possible implementation, when the processing module 73 determines the secondary keyword according to the additional parameter in the request message, the processing module 73 is configured to query a matching table according to the additional parameter to determine the secondary keyword, the matching table storing a mapping relationship between an additional parameter and a secondary keyword, the additional parameter including at least one of the following parameters: a request protocol version, a value of a request header, and any one query string in the target URL.

[0191] In a possible implementation, the sending module 74 is further configured to send the request message to a source server when the target resource file is not cached in the resource file set or the resource file set is not cached in the cache server.

[0192] The receiving module 71 is further configured to receive a source response message from the source server, the source response message carrying the target resource file, a corresponding relationship between the target resource file and the primary keyword, and a corresponding relationship between the target resource file and the secondary keyword.

[0193] The processing module 73 is further configured to cache the target resource file, the corresponding relationship between the target resource file and the primary keyword, and the corresponding relationship between the target resource file and the secondary keyword.

[0194] In a possible implementation, the determining module 72 is configured to determine the target URL according to the request message, determine an effective field from the target URL when the target URL carries a question mark, determine the primary keyword according to the effective field and a request method indicated by the request message, the effective field containing characters before the question mark in the target URL, and determine the primary keyword according to the target URL and the request method indicated by the request message when the target URL does not carry a question mark.

[0195] In a possible implementation, before determining the target resource file from the resource file set corresponding to the primary keyword, the processing module 73 determines whether a mapping rule is configured on the cache server, the mapping rule being used to indicate a corresponding relationship between an initial value of the primary keyword and a mapping value, one mapping value corresponding to at least two initial values; and when the mapping rule is not configured on the cache server, the resource file set is determined according to the initial value of the primary keyword.

[0196] In a possible implementation, when the mapping rule is configured on the cache server, the processing module 73 is further configured to determine a mapping value of the primary keyword according to the initial value of the primary keyword, and determine the resource file set according to the mapping value of the primary keyword.

[0197] In a possible implementation, the receiving module 71 is further configured to receive a change instruction, the change instruction being used to instruct to delete or update the resource file set corresponding to the primary keyword.

[0198] The processing module 73 is further configured to delete or update the resource file set.

[0199] Figure 8 A structural schematic diagram of an electronic device is provided in the embodiment of the present application. As shown in the figure, the electronic device 800, for example, is the cache server described above, and the electronic device 800 includes: Figure 8

[0200] a processor 81 and a memory 82;

[0201] The memory 82 stores computer instructions.

[0202] The processor 81 executes the computer instructions stored in the memory 82, so that the processor 81 performs the resource response method implemented by the cache server.

[0203] The specific implementation process of the processor 81 can refer to the method embodiments described above, which have similar implementation principles and technical effects, and will not be described here again in the embodiment.

[0204] Optionally, the electronic device 800 further includes a communication component 83. The processor 81, the memory 82, and the communication component 83 can be connected through a bus 84.

[0205] The embodiment of the present application further provides a computer readable storage medium, and the computer readable storage medium stores computer instructions. The computer instructions are executed by a processor to implement the resource response method implemented by the cache server.

[0206] ​The embodiment of the present application further provides a computer program product, which contains a computer program, and the computer program is executed by a processor to realize the resource response method implemented by the cache server.

[0207] Other embodiments of the application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the specification and examples be considered as exemplary only, with the true scope and spirit of the application being indicated by the following claims.

[0208] It should be understood that the application is not limited to the precise construction that has been described above and shown in the accompanying drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the application. The scope of the application is indicated only by the appended claims.

Claims

1. A resource response method, characterized by, The method is applied to a cache server and comprises the following steps: receiving a request message from a terminal device, the request message being used to request a target resource file; determining a first keyword of a target URL according to the request message, the first keyword not containing a query string in the target URL, the target URL being a URL indicated by the request message; determining the target resource file from a resource file set corresponding to the first keyword, the resource file set being used to store resource files provided by a source station for the target URL, the target URL corresponding to multiple first keywords, different first keywords corresponding to different resource file sets, the cache server caching resource files in a structure of first keyword+second keyword, the first keyword being used to determine the resource file set, the second keyword being used to determine the target resource file from the resource file set containing multiple resource files, the source station providing multiple resource files for the target URL, the multiple resource files being a sum of resource files in the resource file set corresponding to each first keyword; sending a response message carrying the target resource file to the terminal device.

2. The method of claim 1, wherein, The step of determining the target resource file from the resource file set corresponding to the first keyword comprises the following steps: determining a second keyword according to an additional parameter in the request message, different second keywords of the same URL corresponding to different resource files; determining the target resource file from the resource file set according to the second keyword.

3. The method of claim 2, wherein, The step of determining the second keyword according to the additional parameter in the request message comprises the following steps: querying a matching table according to the additional parameter to determine the second keyword, the matching table storing a mapping relationship between additional parameters and second keywords, the additional parameter including at least one of the following parameters: a request protocol version, a value of a request header, and any one query string in the target URL.

4. The method of claim 2, wherein, The method further comprises the following steps: when the target resource file is not cached in the resource file set or the resource file set is not cached in the cache server, sending the request message to a source server; receiving a source response message from the source server, the source response message carrying the target resource file, a corresponding relationship between the target resource file and the first keyword, and a corresponding relationship between the target resource file and the second keyword; caching the target resource file, the corresponding relationship between the target resource file and the first keyword, and the corresponding relationship between the target resource file and the second keyword.

5. The method according to any one of claims 1 to 4, characterized in that, The step of determining the first keyword according to the request message comprises the following steps: determining the target URL according to the request message; when the target URL carries a question mark, determining an effective field from the target URL, and determining the first keyword according to the effective field and a request method indicated by the request message, the effective field containing characters before the question mark in the target URL; when the target URL does not carry a question mark, determining the first keyword according to the target URL and the request method indicated by the request message.

6. The method according to any one of claims 1 to 4, characterized in that, Before the target resource file is determined from the resource file set corresponding to the primary keyword, the method further comprises: determining whether a mapping rule is configured on the cache server, the mapping rule being used to indicate a corresponding relationship between an initial value of the primary keyword and a mapping value of the primary keyword; when the mapping rule is not configured on the cache server, determining the resource file set according to the initial value of the primary keyword.

7. The method of claim 6, wherein, Further comprising: when the mapping rule is configured on the cache server, determining the mapping value of the primary keyword according to the initial value of the primary keyword; determining the resource file set according to the mapping value of the primary keyword.

8. The method according to any one of claims 1 to 4, characterized in that, Further comprising: receiving a change instruction, the change instruction being used to indicate that a resource file set corresponding to the primary keyword is deleted or updated; deleting or updating the resource file set.

9. An electronic device comprising a processor, a memory, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to enable the electronic device to implement the method of any one of claims 1 to 8.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the method of any one of claims 1 to 8.

Citation Information

Patent Citations

  • Video cache acceleration method and device

    CN109089175A

  • Data processing method and device, medium and equipment

    CN115145879A