Communication method and device
By using adaptive caching technology, network devices automatically adjust caching rules, solving the problem that existing WebCache technology cannot meet users' changing needs, and improving system performance and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-04-10
AI Technical Summary
Existing WebCache technology cannot meet users' complex and ever-changing caching needs, and manually setting caching rules is time-consuming, labor-intensive, and costly.
In adaptive caching mode, network devices automatically find and adjust caching rules by receiving packet characteristics, dynamically match user needs, and generate adaptive caching rules.
It improved cache hit rate, reduced setup and maintenance costs, and enhanced user experience and satisfaction.
Smart Images

Figure CN121842276A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a communication method and apparatus. Background Technology
[0002] With the rapid development of the internet, website content has become richer and more dynamic, and the frequency of user resource requests has increased significantly. At the same time, various network performance bottlenecks have emerged. For example, users experience high latency, slow loading, and longer server response times when accessing remote servers, severely impacting the user experience.
[0003] To address this challenge, in addition to browser caching, server-side caching technologies have been introduced. Server-side caching can store dynamically generated content or processed static resources. For example, reverse proxy servers (Nginx) and dedicated caching servers (Redis) can be used.
[0004] Applications using protocols such as FTP and HTTP on the network generate a large amount of redundant and repetitive traffic. WebCache technology can be used to customize caching rules based on network and user needs (e.g., setting cached file types). High-bandwidth applications within the network, such as large files, videos, and application update packages, can be cached locally on network devices, reducing data transmission traffic on the WAN link and alleviating bandwidth pressure. Simultaneously, this improves access speed for user terminals, enhancing network efficiency and user experience.
[0005] Today, the ways and types of resources requested by users on the network are complex and varied. Existing WebCache technology has also exposed the following shortcomings: 1) For complex and varied user request methods (e.g., requests using different browsers or different protocol types) and resource types (e.g., static and dynamic resources, file size, file type, etc.), manually setting the caching rules in the Nginx configuration file cannot ensure that all user requests can be completely matched with the caching rules, resulting in failure to meet users' ideal caching needs; 2) If the network environment changes, it is necessary to manually set the caching rules again, which is time-consuming, labor-intensive, and costly. Summary of the Invention
[0006] In view of this, this application provides a communication method and apparatus to solve the problems of existing WebCache technology, such as the inability to meet all caching needs and high costs associated with manually setting caching rules.
[0007] In a first aspect, this application provides a communication method applied to a network device, the method comprising: Receive a first message, the first message including message characteristics; If the network device has enabled adaptive caching, it searches locally for a first caching rule that matches the original feature values included in the packet features; If the first caching rule exists and the message features include an update feature value, then the first caching rule is adjusted based on the update feature value and the first comprehensive caching feature to obtain the second caching rule.
[0008] Secondly, this application provides a communication device applied to a network device, the device comprising: A receiving unit is configured to receive a first message, the first message including message characteristics; The lookup unit is configured to, if the network device has enabled adaptive caching, search locally for a first caching rule that matches the original feature value included in the packet features; An adjustment unit is configured to, if the first caching rule exists and the message includes an update feature value, adjust the first caching rule according to the update feature value and the first comprehensive caching feature to obtain a second caching rule.
[0009] Thirdly, this application provides a network device including a processor and a machine-readable storage medium storing machine-executable instructions that can be executed by the processor, which in turn cause the processor to perform the method provided in the first aspect of this application.
[0010] Therefore, using the communication method and apparatus provided in this application, a network device receives a first message, which includes message features; if the network device has enabled adaptive caching, the network device searches locally for a first caching rule that matches the original feature value included in the message features; if a first caching rule exists and the message features include an updated feature value, the network device adjusts the first caching rule according to the updated feature value and the first caching comprehensive feature to obtain a second caching rule.
[0011] In this way, with adaptive caching enabled, network devices automatically capture and analyze the characteristics of packets passing through them, dynamically adjusting existing caching rules to improve cache hit rates and network device system performance, effectively saving on setup and subsequent maintenance costs. Simultaneously, it also enhances user satisfaction and experience. This solves the problems of manual caching rule setting in existing WebCache technologies, which cannot meet all caching needs and are costly. Attached Figure Description
[0012] Figure 1 A flowchart illustrating the communication method provided in the embodiments of this application; Figure 2 A structural diagram of a communication device provided in an embodiment of this application; Figure 3 The network device hardware structure provided in the embodiments of this application. Detailed Implementation
[0013] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0014] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the corresponding listed items.
[0015] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0016] The communication method provided in the embodiments of this application will be described in detail below. See also... Figure 1 , Figure 1 This is a flowchart illustrating a communication method provided in an embodiment of this application. The method is applied to a network device, which may specifically be a router or a device supporting web cache functionality. The communication method provided in this application embodiment may include the following steps.
[0017] Step 110: Receive the first message, which includes message characteristics; Specifically, the network device is positioned between the client and the server, and forwards the messages sent by the client or the server to the other end respectively.
[0018] Network devices receive messages sent by clients or servers, such as the first message. The network device then extracts message characteristics from the first message.
[0019] Optionally, in the embodiments of this application, the first message may specifically be a client request or a server response.
[0020] Optionally, in this embodiment of the application, the above-mentioned message features specifically include message header information, URL protocol information, path information, parameter information, status code, content type, and size of the resource to be cached.
[0021] For example, if the first message is a client request, the message header information includes, but is not limited to, the following fields: Host field, Connection field, Content-Length field, Accept-Encoding field, Transfer-Encoding field, TE field, Keep-Alive field, ExpectUpgrade field, X-File-Version field, User-Agent field, etc.; if the first message is a server response, the message header information includes, but is not limited to, the following fields: public field, private field, Cache-Control field, Expires field, Date field, Server field, X-Pad field, Access-Control-Allow-Origin field, Vary field, Trailer field, etc.
[0022] For example, path information indicates the location of the resource to be cached on the server, with levels separated by " / ", although in some special cases " / / " may be used. Path information can be a single-level directory or a multi-level directory.
[0023] For example, the parameter information may be "param=value" included in the URL or may include query parameters.
[0024] For example, the status code is a value returned by the server in the response, such as 200, 400, 404, 500, etc.
[0025] For example, the content type is specifically static file, dynamic file, or mp4, txt, doc, etc.; For example, the size of the resource to be cached specifically refers to the size of the file to be cached; large files involve fragmentation and other processing.
[0026] It is understandable that the above message characteristics may carry different characteristics depending on the type of the first message. For example, the above status code is usually carried in the server response.
[0027] Step 120: If the network device has enabled adaptive caching, then it searches locally for a first caching rule that matches the original feature value included in the packet features; Specifically, according to the description of step 110, after the network device obtains the packet characteristics, the network device first identifies whether it has started adaptive caching.
[0028] If the network device has enabled adaptive caching, the network device will search locally for a first caching rule that matches the packet characteristics, including the original feature value.
[0029] If a first caching rule exists locally, the network device executes step 130.
[0030] Optionally, in this embodiment of the application, if the first caching rule does not exist locally, the network device generates the first caching rule based on the original feature value and the second comprehensive caching feature. The first caching rule includes the original feature value and the caching strategy of the resource to be cached.
[0031] Optionally, in this embodiment of the application, the second cache comprehensive features include resource access rules, applicable rules for local cache, and device attributes; The specific process by which the network device generates the first cache rule based on the original feature value and the comprehensive feature of the second cache is as follows: The network device uses the resource access rules, the applicable rules of the local cache, and the device attributes to determine the caching strategy (including caching resources or not caching resources); The network device uses the original feature value as the cache key and the caching strategy as the execution action to generate the first cache rule.
[0032] Furthermore, the aforementioned original feature values include the attribute values corresponding to each field included in the message features, and the number of attribute values can be one or more.
[0033] The access rules for the aforementioned resources can be specifically defined as the access frequency of each resource recorded by the network device. For example, if the access frequency of a resource is low, such as when the access frequency has not reached the access threshold (e.g., the access threshold is 3 times), the network device sets the resource not to be cached, or caches the resource when the access frequency reaches the access threshold. If the access frequency of a resource is high, such as when the access frequency has reached the access threshold, the network device sets the resource to be cached preferentially.
[0034] It should be noted that the network device includes an nginx.conf file, which stores caching rules.
[0035] Typically, the access threshold is set to 1, meaning that accessing a resource once is sufficient to meet the caching rules, and the network device caches the resource locally. However, this can significantly consume the network device's storage space. In practical applications, network devices determine whether a resource should be cached locally by counting the frequency of client accesses.
[0036] The applicable rules for the above caching can be specifically defined as monitoring cache hit rate and cache expiration status on network devices. The cache hit rate refers to the probability that a resource cached locally on the network device is requested by a client, and the cache expiration status refers to the fact that a resource cached locally on the network device is no longer requested by a client and has been replaced by a new resource.
[0037] The aforementioned device attributes can be specifically the hardware and software capabilities of the network device, such as the network device's CPU parameters, memory space size, etc.
[0038] In this embodiment, the network device adjusts parameters such as cache space and cache aging time based on access rules, usage rules, and device attributes. Taking into account the aforementioned rules, device attributes, and parameters, a comprehensive value is calculated by assigning weights to each rule, attribute, and parameter (e.g., assigning weights individually if the total weight sums to 1). Based on this comprehensive value, a caching strategy is further determined. For example, if the comprehensive value exceeds a preset threshold, caching occurs; otherwise, caching does not occur.
[0039] Step 130: If the first caching rule exists and the message features include an update feature value, then adjust the first caching rule according to the update feature value and the first comprehensive caching feature to obtain the second caching rule.
[0040] Specifically, according to the description of step 120, when the network device searches locally for a first cache rule that matches the packet features including the original feature value, if the first cache rule exists locally, the network device continues to identify whether the packet features also include an updated feature value.
[0041] If the message features include an updated feature value, the network device adjusts the first cache rule based on the updated feature value and the first cache comprehensive feature to obtain the second cache rule.
[0042] Furthermore, the aforementioned updated feature values include newly added feature values determined by the network device from the packet features, as well as feature values deleted by the network device after comparing them with the packet features according to the first caching rule. The aforementioned current cached features include resource access rules, cache usage rules, and device attributes.
[0043] It is understandable that caching rules include a cache key and a caching strategy for the resource to be cached. The cache key can be a specific message characteristic, and the caching strategy can be a specific action to be performed on the resource to be cached.
[0044] When adjusting the first caching rule, the network device can adjust the cache key and caching policy separately to obtain the second caching rule.
[0045] In this embodiment of the application, each of the aforementioned message features may include multiple attribute values simultaneously. For example, the Host field may include multiple Host values, the Server field may include multiple Server IP addresses, and other fields are similar and will not be repeated here.
[0046] When a client sends a request or a server sends a response, the original feature values may be updated. For example, an attribute value may be added to or deleted from a field. When the network device receives the request from the client or the response from the server again, during packet feature matching, if any original feature value of each field included in the packet features matches the value of the corresponding field included in the caching rule, the packet is determined to match the caching rule. The network device then checks whether there are any added or deleted updated feature values in each field. If updated feature values exist, the network device also adds or deletes the corresponding field value.
[0047] For example, the Host field includes the original characteristic values Host1 and Host2, and the Server field includes the original characteristic values IP1 and IP2. When the network device searches for cache rules locally, it finds cache rule 1 that matches Host1, Host2, IP1, and IP2. This cache rule 1 includes Host1, Host2, IP1, IP2, and IP3.
[0048] The network device retrieves the updated feature value Host3 from the Host field again, and determines the updated feature value IP3 in the Server field based on IP3 included in Cache Rule 1. At this point, when adjusting Cache Rule 1, the network device adds Host3 to the Host field included in Cache Rule 1 and removes IP3 from the Server field, resulting in Cache Rule 2, which includes Host1, Host2, Host3, IP1, and IP2.
[0049] After adjusting the cache key, the network device can also adjust the caching policy. The process of adjusting the caching policy can be the same as or similar to the caching policy included in the first caching rule, and will not be repeated here. That is, based on access rules, usage rules, and device attributes, the network device adjusts parameters such as cache space and cache aging time, and further adjusts the caching policy (caching resources or not caching resources).
[0050] Understandably, the network device will replace the first cache rule with the adjusted second cache rule and store it in the nginx.conf file.
[0051] As illustrated by the examples above, network devices can dynamically adjust caching rules based on received packets without requiring manual adjustments by administrators, thus meeting user caching needs while reducing costs.
[0052] Optionally, in this embodiment of the application, when the first message is a server response, after obtaining the second caching rule, the network device can also perform corresponding caching processing on the resources to be cached included in the first message according to the second caching rule.
[0053] Furthermore, according to the second caching rule, the network device decides whether to cache the resource to be cached.
[0054] Optionally, in this embodiment of the application, if the network device does not start adaptive caching, the network device will automatically switch to manual caching.
[0055] Furthermore, when enabling the WebCache caching service, network devices have two caching rule adjustment modes: manual caching and adaptive caching. Whether to enable adaptive caching depends on the network's business traffic and user needs. For example, in scenarios with low-frequency business traffic fluctuations and simple user needs (typically referring to a single packet type and a single type of accessed resource), manual caching is used instead of adaptive caching. For scenarios with complex and variable business traffic (typically referring to a large number of clients, high access volume, and complex types of accessed resources, or complex types of accessed websites and resource adjustments), adaptive dynamic adjustment mode is recommended. This mode only needs to be enabled during the initial setup phase, and no further maintenance or modification of caching rules is required later.
[0056] Therefore, using the communication method provided in this application, a network device receives a first message, which includes message features; if the network device has enabled adaptive caching, the network device searches locally for a first caching rule that matches the original feature value included in the message features; if a first caching rule exists and the message features include updated feature values, the network device adjusts the first caching rule according to the updated feature values and the first caching comprehensive features to obtain a second caching rule.
[0057] In this way, with adaptive caching enabled, network devices automatically capture and analyze the characteristics of packets passing through them, dynamically adjusting existing caching rules to improve cache hit rates and network device system performance, effectively saving on setup and subsequent maintenance costs. Simultaneously, it also enhances user satisfaction and experience. This solves the problems of manual caching rule setting in existing WebCache technologies, which cannot meet all caching needs and are costly.
[0058] Based on the same inventive concept, embodiments of this application also provide a communication device corresponding to the communication method. See also Figure 2 , Figure 2 The communication device provided in this application embodiment is applied to a network device, and the device includes: The receiving unit 210 is configured to receive a first message, the first message including message characteristics; The lookup unit 220 is configured to, if the network device has enabled adaptive caching, search locally for a first caching rule that matches the original feature value included in the packet features; The adjustment unit 230 is used to adjust the first cache rule according to the updated feature value and the first cache comprehensive feature if the first cache rule exists and the message includes an updated feature value, so as to obtain a second cache rule.
[0059] Optionally, the device further includes: The generation unit (not shown in the figure) is used to generate the first cache rule based on the original feature value and the second cache comprehensive feature if the first cache rule does not exist. The first cache rule includes the original feature value and the caching strategy of the resource to be cached.
[0060] Optionally, the second cache comprehensive features include resource access rules, applicable rules for local cache, and device attributes; The generation unit (not shown in the figure) is specifically used to determine the caching strategy by utilizing the resource access rules, the applicable rules of the local cache, and device attributes; to generate the first caching rule by using the original feature value as the cache key and the caching strategy as the execution action.
[0061] Optionally, when the first message is a server response, the apparatus further includes: The processing unit (not shown in the figure) is used to perform corresponding caching processing on the resources to be cached included in the first message according to the second caching rule.
[0062] Optionally, the first message is a client request or a server response; The message characteristics include message header information, URL protocol information, path information, parameter information, status code, content type, and the size of the resource to be cached.
[0063] Therefore, using the communication device provided in this application, the network device receives a first message, which includes message features; if the network device has enabled adaptive caching, the network device searches locally for a first caching rule that matches the original feature value included in the message features; if a first caching rule exists and the message features include an updated feature value, the network device adjusts the first caching rule according to the updated feature value and the first caching comprehensive feature to obtain a second caching rule.
[0064] In this way, with adaptive caching enabled, network devices automatically capture and analyze the characteristics of packets passing through them, dynamically adjusting existing caching rules to improve cache hit rates and network device system performance, effectively saving on setup and subsequent maintenance costs. Simultaneously, it also enhances user satisfaction and experience. This solves the problems of manual caching rule setting in existing WebCache technologies, which cannot meet all caching needs and are costly.
[0065] Based on the same inventive concept, embodiments of this application also provide a network device, such as... Figure 3 As shown, the system includes a processor 310, a transceiver 320, and a machine-readable storage medium 330. The machine-readable storage medium 330 stores machine-executable instructions that can be executed by the processor 310. The processor 310 is prompted by the machine-executable instructions to execute the communication method provided in the embodiments of this application. (The foregoing...) Figure 2 The communication device shown can be used as follows: Figure 3 The hardware structure of the network device shown is implemented.
[0066] The aforementioned computer-readable storage medium 330 may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the computer-readable storage medium 330 may also be at least one storage device located remotely from the aforementioned processor 310.
[0067] The processor 310 mentioned above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0068] In this embodiment of the application, the processor 310 reads the machine-executable instructions stored in the machine-readable storage medium 330, and is prompted by the machine-executable instructions to enable the processor 310 itself and the transceiver 320 to execute the communication method described in the foregoing embodiment of the application.
[0069] In addition, this application provides a machine-readable storage medium 330 that stores machine-executable instructions. When called and executed by the processor 310, the machine-executable instructions cause the processor 310 itself and the transceiver 320 to execute the communication method described in the aforementioned application.
[0070] The specific implementation process of the functions and roles of each unit in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0071] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0072] For the embodiments of communication devices and machine-readable storage media, since the methods involved are basically similar to those of the aforementioned method embodiments, the description is relatively simple, and relevant details can be found in the descriptions of the method embodiments.
[0073] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A communication method, characterized in that, Applied to network devices, the method includes: Receive a first message, the first message including message characteristics; If the network device has enabled adaptive caching, it searches locally for a first caching rule that matches the original feature values included in the packet features; If the first caching rule exists and the message features include an update feature value, then the first caching rule is adjusted based on the update feature value and the first comprehensive caching feature to obtain the second caching rule.
2. The method according to claim 1, characterized in that, The method further includes: If the first caching rule does not exist, the first caching rule is generated based on the original feature value and the second comprehensive caching feature. The first caching rule includes the original feature value and the caching strategy of the resource to be cached.
3. The method according to claim 2, characterized in that, The second comprehensive cache feature includes resource access rules, applicable rules for local cache, and device attributes; The step of generating the first cache rule based on the original feature value and the second cache comprehensive feature specifically includes: The caching strategy is determined using the resource access rules, the applicable rules for the local cache, and device attributes; The original feature value is used as the cache key, and the cache strategy is used as the execution action to generate the first cache rule.
4. The method according to claim 1, characterized in that, When the first message is a server response, the method further includes: According to the second caching rule, the resources to be cached included in the first message are cached accordingly.
5. The method according to claim 1, characterized in that, The first message is either a client request or a server response; The message characteristics include message header information, URL protocol information, path information, parameter information, status code, content type, and the size of the resource to be cached.
6. A communication device, characterized in that, Applied to network devices, the device includes: A receiving unit is configured to receive a first message, the first message including message characteristics; The lookup unit is configured to, if the network device has enabled adaptive caching, search locally for a first caching rule that matches the original feature value included in the packet features; An adjustment unit is configured to, if the first caching rule exists and the message includes an update feature value, adjust the first caching rule according to the update feature value and the first comprehensive caching feature to obtain a second caching rule.
7. The apparatus according to claim 6, characterized in that, The device further includes: The generation unit is configured to generate the first cache rule based on the original feature value and the second cache comprehensive feature if the first cache rule does not exist. The first cache rule includes the original feature value and the caching strategy of the resource to be cached.
8. The apparatus according to claim 7, characterized in that, The second comprehensive cache feature includes resource access rules, applicable rules for local cache, and device attributes; The generation unit is specifically used to determine the caching strategy by utilizing the resource access rules, the applicable rules of the local cache, and device attributes; and to generate the first caching rule by using the original feature value as the cache key and the caching strategy as the execution action.
9. The apparatus according to claim 6, characterized in that, When the first message is a server response, the apparatus further includes: The processing unit is configured to perform corresponding caching processing on the resources to be cached included in the first message according to the second caching rule.
10. The apparatus according to claim 6, characterized in that, The first message is either a client request or a server response; The message characteristics include message header information, URL protocol information, path information, parameter information, status code, content type, and the size of the resource to be cached.