Resource refreshing method and system
By managing cache location records in the scheduling server's database and generating URLs for different domains, the bandwidth limitation problem of edge devices is solved, enabling optimization of edge device performance and timely updates of client resource files.
Patent Information
- Application Number
- CN202511476640.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-15
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2045-10-15
AI Technical Summary
Because edge devices have limited bandwidth, performing a large number of resource file refreshes on edge devices can cause performance fluctuations, leading to abnormal resource file retrieval by the client.
The cache location record of the resource file is deleted from the database of the scheduling server, and the edge device is instructed to directly return the locally cached resource file or perform an update verification by generating URLs with different domain names to obtain the latest resource file.
This reduces the performance overhead on edge devices, ensuring that clients obtain the latest resource files without requiring a unified refresh operation on the edge devices.
Smart Images

Figure CN120929687B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of resource refresh technology, and in particular to resource refresh methods and systems. Background Technology
[0002] In practical applications, when accessing resource files via clients, the origin server is geographically dispersed, resulting in slow file retrieval speeds due to the distance between the clients and the origin server. Therefore, resource files from the origin server are typically cached on multiple edge devices to allow clients to access them from the nearest location, reducing latency. However, when the resource files on the origin server are updated, the cached files on the edge devices may not yet be updated, potentially leading the client to retrieve older files from the edge devices. Therefore, when the resource files on the origin server are updated, all edge devices must also be refreshed to update their cached resource files.
[0003] However, due to the limited bandwidth of edge devices, performing a large number of refreshes on edge devices can cause performance fluctuations, leading to abnormalities in the client's retrieval of resource files. Summary of the Invention
[0004] In view of this, this application provides a resource refresh method and system to reduce the impact of resource file refresh on the performance of edge devices.
[0005] The technical solution provided in this application is as follows:
[0006] According to an embodiment of the first aspect of this application, a resource refresh method is proposed, which is applied to a scheduling server, and the method includes:
[0007] When a resource refresh instruction is received for any resource file, if a cache location record for that resource file exists in the database, the corresponding cache location record for that resource file will be deleted.
[0008] Upon receiving a resource access request from a client, the system determines whether a cache location record of the requested resource file exists in the database based on the original URL carried in the resource access request.
[0009] If so, a first URL is generated, which includes the original URL, a first domain name, and an identifier of the target edge device corresponding to the cache location record of the requested resource file; the first URL is returned to the client so that the client sends a client redirection request to the target edge device based on the first URL; the first domain name is used to indicate that when the target edge device receives the client redirection request, if the target edge device has cached the resource file locally, it will directly return the resource file.
[0010] If not, a second URL is generated, which includes the original URL, a second domain name, and an identifier for the target edge device assigned to the resource file; the second URL is returned to the client so that the client sends a client redirection request to the target edge device based on the second URL; the second domain name is used to indicate that when the target edge device receives the client redirection request, if the target edge device has the resource file cached locally, it should update and verify the resource file to obtain the latest resource file; wherein, the second domain name is different from the first domain name.
[0011] Optionally, the identifier of the target edge device includes the IP address of the target edge device, and generating the first URL includes:
[0012] The IP address of the target edge device is encrypted to obtain an encryption prefix, and the first URL is generated based on the encryption prefix, the first domain name, and the original URL;
[0013] The generation of the second URL includes:
[0014] Select a target edge device from the edge devices connected to the scheduling server; encrypt the IP address of the target edge device to obtain an encryption prefix, and generate the second URL based on the encryption prefix, the second domain name, and the original URL.
[0015] Optionally, the first domain name and the second domain name are different wildcard domain names; or, the first domain name and the second domain name are the same wildcard domain name with different prefix identifiers.
[0016] Optionally, the database also records the latest access time of each resource file, and the method further includes:
[0017] Upon receiving a resource refresh instruction for any directory, the directory refresh rule for that directory to be refreshed is recorded in the database; the directory refresh rule includes the directory to be refreshed and the creation time of the directory refresh rule.
[0018] When a resource access request is received from a client, if the database is determined to contain a cache location record of the requested resource file based on the original URL carried in the resource access request sent by the client, the method further includes: detecting whether the latest access time of the resource file is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs;
[0019] If the latest access time of the resource file is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs, then the step of generating the second URL is executed;
[0020] If the latest access time of the resource file is not earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs, then continue to execute the step of generating the first URL.
[0021] Optionally, the database also records the latest access time of each resource file, and the method further includes:
[0022] Upon receiving a resource refresh instruction for any directory, the directory refresh rule for that directory to be refreshed is recorded in the database; the directory refresh rule includes the directory to be refreshed and the creation time of the directory refresh rule.
[0023] When a resource access request is received from a client, if the original URL carried in the resource access request belongs to any directory to be refreshed, a third URL is generated. The third URL includes the original URL, the creation time of the directory refresh rule of the directory to be refreshed, and the identifier of the target edge device corresponding to the resource file.
[0024] The third URL is returned to the client so that the client sends a client redirection request to the target edge device based on the third URL; the third URL is used to instruct the target edge device, after receiving the client redirection request, to obtain the latest resource file based on the creation time of the locally cached resource file and the creation time of the directory refresh rule, if the resource file is cached locally on the target edge device.
[0025] According to an embodiment of the second aspect of this application, a resource refresh method is proposed, which is applied to an edge device, and the method includes:
[0026] Receive a client redirection request sent by the client; the client redirection request is sent by the client to the edge device after receiving the URL sent by the scheduling server;
[0027] Based on the original URL carried in the client redirection request, detect whether the edge device has cached the resource file requested by the client redirection request locally;
[0028] If not, the latest resource file is obtained based on the original URL and returned to the client;
[0029] If so, when the domain name carried in the client redirection request is the first domain name, the resource file already cached in the edge device is returned to the client; when the domain name carried in the client redirection request is the second domain name, the resource file cached locally in the edge device is updated and verified according to the original URL to return the latest resource file to the client.
[0030] Optionally, the step of updating and verifying the resource file locally cached on the edge device based on the original URL to return the latest resource file to the client includes:
[0031] Send a file verification request carrying a verification request header to the origin server of the original URL; the verification request header carries the attribute information of the resource file requested by the resource acquisition request cached in the edge device; the file verification request is used to request the origin server to check whether the resource file has been updated based on the attribute information of the resource file.
[0032] If a first response is received from the origin server, indicating that the resource file has been updated, the updated resource file is downloaded from the origin server and returned to the client.
[0033] If a second response is received from the origin server, indicating that the resource file has not been updated, then the resource file cached in the edge device is directly returned to the client.
[0034] Optionally, the attribute information includes at least one of the following:
[0035] The resource acquisition request requests the timestamp, MD5 value, and version number of the resource file.
[0036] Optionally, the method further includes:
[0037] If the client redirection request sent by the client carries the creation time of the directory refresh rule of the directory to be refreshed to which the original URL belongs, then if the resource file requested by the client redirection request is cached locally on the edge device, the creation time of the resource file requested by the client redirection request cached locally on the edge device is compared with the creation time of the directory refresh rule.
[0038] If the creation time of the resource file requested by the client redirection request cached locally on the edge device is earlier than the creation time of the directory refresh rule, then the resource file is updated and verified according to the original URL to return the latest resource file to the client;
[0039] If the creation time of the resource file requested by the client redirection request and cached locally on the edge device is not earlier than the creation time of the directory refresh rule, then the resource file requested by the client redirection request and cached locally on the edge device will be directly returned to the client.
[0040] According to an embodiment of the third aspect of this application, a resource refresh system is proposed, comprising:
[0041] A scheduling server, communicatively connected to at least one client and at least one edge device, is used to perform the method as described in the first aspect;
[0042] The client is communicatively connected to the scheduling server and at least one edge device, and is used to send a resource access request to the scheduling server, and after receiving the URL returned by the scheduling server, send a client redirection request to the corresponding edge device based on the URL.
[0043] Edge devices are used to perform the method described in the second aspect.
[0044] As can be seen from the above technical solution, when a resource file needs to be refreshed, this application does not require a refresh operation on the edge device. Instead, it deletes the cache location record corresponding to the resource file from the database associated with the scheduling server. Then, when a resource access request is received from the client, a first domain name is set for resource files that do not require update verification, instructing the target edge device to directly return the resource file if it has it cached locally. For resource files that require refresh, a second domain name is set, instructing the edge device to update and verify the resource file if it has it cached locally, thus obtaining the latest resource file. Through this solution, a unified refresh operation on the edge device is unnecessary, while still ensuring the client receives the latest resource file, reducing the performance overhead on the edge device. Attached Figure Description
[0045] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the principles of this application.
[0046] Figure 1 This application provides a schematic diagram of a resource refresh system architecture in a related art.
[0047] Figure 2 This is a flowchart of a resource refresh method applied to a scheduling server, provided in an embodiment of this application.
[0048] Figure 3 This is a flowchart illustrating a resource refresh method for edge devices provided in an embodiment of this application.
[0049] Figure 4 This application provides a multi-party interaction diagram for scenarios where resource file verification is not required, as shown in the embodiments of this application.
[0050] Figure 5 This application provides a multi-party interaction diagram for scenarios requiring resource file refresh in its embodiments.
[0051] Figure 6This application provides a multi-party interaction diagram for a directory refresh scenario that does not require resource file verification.
[0052] Figure 7 This application provides a multi-party interaction diagram for a directory refresh scenario that requires resource file refresh;
[0053] Figure 8 This application provides a multi-party interaction diagram for another directory refresh scenario requiring resource file refresh, as shown in the embodiments of this application.
[0054] Figure 9 A structural diagram of a resource refresh device applied to a scheduling server is provided in an embodiment of this application;
[0055] Figure 10 A structural diagram of a resource refresh device applied to an edge device provided in an embodiment of this application;
[0056] Figure 11 This is a schematic diagram of a resource refresh system architecture provided in an embodiment of this application. Detailed Implementation
[0057] To enable those skilled in the art to better understand the technical solutions provided in the embodiments of this application, and to make the above-mentioned objectives, features and advantages of the embodiments of this application more apparent and understandable, the technical solutions in the embodiments of this application will be further described in detail below with reference to the accompanying drawings.
[0058] When accessing resource files via a client, the origin server is often geographically dispersed, resulting in slow file retrieval speeds. Therefore, in practice, resource files from the origin server are typically cached on multiple edge devices, allowing clients to access them from the nearest available device and reducing latency.
[0059] The following is through Figure 1 This paper provides a brief introduction to the refresh mechanism of resource refresh systems in related technologies.
[0060] Please refer to Figure 1 , Figure 1 This is a schematic diagram of a resource refresh system architecture in a related art provided for an embodiment of this application.
[0061] like Figure 1 As shown, this description uses the PCDN (Peer-to-Peer Content Delivery Network) system as an example. PCDN is a CDN (Content Delivery Network) system that utilizes limited bandwidth resources. In PCDN, refresh is usually achieved using the 302 return code in the HTTP protocol.
[0062] Specifically, the resource refresh system includes a client, a 302 scheduling server, multiple edge devices registered in the 302 scheduling server, and a database that records the correspondence between each resource file and the edge devices (i.e., which edge devices or which edge devices each resource file is cached in).
[0063] The following example illustrates the resource file acquisition and refresh mechanisms in this resource refresh system:
[0064] When a client (such as a mobile app) requests access to a resource file, taking the URL (Uniform Resource Locator) of the requested resource file as http: / / AAA.com / vedio1.mp4 as an example, the client sends the URL of the requested resource file to the 302 scheduling server. The 302 scheduling server then queries its database to see if the resource file already exists on a certain edge device.
[0065] If the resource file has been accessed by any client, the 302 scheduling server will store the URL of the resource file and the corresponding edge device identifier (such as the IP address of the edge device) in the database.
[0066] If the requested resource file exists on a certain edge device, the IP address of that edge device can be directly encrypted, and the encrypted string can be appended to the beginning of another specified domain name, such as xxx.BBB-pcdn.com (where xxx represents the string obtained by encrypting the IP address of the edge device, and BBB-pcdn.com is usually a domain name officially registered by the PCDN service provider, and the DNS authoritative resolution authority of this domain name is set to a dedicated DNS server cluster built and managed by the PCDN service provider).
[0067] Furthermore, the above xxx.BBB-pcdn.com can be appended to the URL of the requested resource file, and the status code 302 (indicating that the client needs to access it again using a new URL) and the newly obtained URL, http: / / xxx.BBB-pcdn.com / AAA.com / vedio1.mp4, can be returned to the client.
[0068] After receiving the aforementioned status code 302, the client then uses the authoritative DNS server of the PCDN service provider to resolve the IP address of the domain name xxx.BBB-pcdn.com in the latest URL. During the resolution process, the authoritative DNS server will decrypt the aforementioned "xxx" to obtain the IP address of the corresponding edge device. In this way, the client can initiate a redirection request to the corresponding edge device based on the IP address in order to obtain resource files from the corresponding edge device.
[0069] When the edge device receives a redirection request, it removes the domain name xxx.BBB-pcdn.com from the URL carried in the redirection request to obtain the original URL (i.e., http: / / AAA.com / vedio1.mp4), and obtains the resource file cached in the edge device based on the original URL, and returns it to the client.
[0070] In this scenario, when the resource files on the origin server are updated, the resource files cached on the edge devices have not yet been updated. At this time, the resource files obtained by the client from the edge devices through the aforementioned resource file retrieval mechanism are likely not the latest version of the resource files. Therefore, when the resource files on the origin server are updated, each edge device also needs to be refreshed to update the cached resource files in each edge device.
[0071] However, due to the limited bandwidth of edge devices, performing a large number of refreshes on edge devices can cause performance fluctuations, leading to abnormalities in the client's retrieval of resource files.
[0072] Based on this, this application proposes a resource refresh method to reduce the impact on edge device performance during the resource file refresh process.
[0073] Please refer to Figure 2 , Figure 2 This is a flowchart illustrating a resource refresh method applied to a scheduling server, as provided in an embodiment of this application.
[0074] The resource refresh method proposed in this embodiment is... Figure 1 The methodological improvements made to the resource refresh system architecture in this paper do not change the architecture of the resource refresh system in related technologies, so as to avoid the cost issues caused by adjusting the overall architecture.
[0075] like Figure 2 As shown, the method may include the following steps:
[0076] Step 201: When a resource refresh instruction for any resource file is received, if a cache location record for that resource file exists in the database, then the cache location record corresponding to that resource file is deleted.
[0077] In this embodiment, when any resource file is updated, the administrator can send a resource refresh instruction for that resource file to the scheduling server. After receiving the resource refresh instruction for that resource file, the scheduling server can search the database that records the cache location records corresponding to each resource file to see if there is a cache location record for that resource file.
[0078] If it exists, it means that the resource file exists in at least one edge device. In this case, the resource file in these edge devices needs to be refreshed. At this time, the cache location record corresponding to the resource file can be deleted from the database so that when any client retrieves the resource file next time, the resource file will be refreshed during the retrieval process. The specific refresh process will be detailed below and will not be repeated here.
[0079] This concludes the description of step 201.
[0080] Step 202: Upon receiving a resource access request from the client, determine whether a cache location record of the requested resource file exists in the database based on the original URL carried in the resource access request sent by the client.
[0081] In this embodiment, when a client needs to access a resource file, it first sends a resource access request to the scheduling server. The resource access request carries the original URL of the resource file to be accessed. After receiving the resource access request, the scheduling server can query the database based on the original URL to see if there is a cache location record of the requested resource file.
[0082] It should be noted that since the cache location record of the resource file that needs to be refreshed has been deleted from the database in step 201, if the cache location record of the requested resource file exists in the database, it indicates that the resource file is not a resource file that needs to be updated and verified (i.e., it does not need to be refreshed).
[0083] If the cache location record of the requested resource file does not exist in the database, the following situations may occur:
[0084] (1) The resource file requested for access is a resource file that needs to be refreshed, and its cache location record is actively deleted from the database.
[0085] (2) The resource file requested for access is a resource file that has not been accessed by any client yet. Since it has never been accessed, there is no cache location record for it in the database.
[0086] (3) The cache location record of the requested resource file is discarded by the database. This is different from the first case. Here, the discarding is because the resource file has not been accessed within a specified time period, the number of resources in the database has reached the maximum capacity, so the cache location records of some resource files that have not been accessed within a specified time period are deleted; or the database crashes and the cache location records are lost.
[0087] In this embodiment, regardless of which of the above situations, the latest resource file can be obtained when the client retrieves the resource file according to the resource refresh method proposed in this application, and the resource file update can be completed during the resource file retrieval process.
[0088] If it is determined that a cache location record for the requested resource file exists in the database, then step 203 is executed; if it is determined that a cache location record for the requested resource file does not exist in the database, then step 204 is executed.
[0089] Step 203: Generate a first URL, which includes the original URL, a first domain name, and the identifier of the target edge device corresponding to the cache location record of the requested resource file; return the first URL to the client so that the client sends a client redirection request to the target edge device based on the first URL; the first domain name is used to indicate that when the target edge device receives the client redirection request, if the target edge device has cached the resource file locally, it will directly return the resource file.
[0090] In this embodiment, step 203 is performed when it is determined that a cache location record of the requested resource file exists in the database. If it is determined that a cache location record of the requested resource file exists in the database, a first URL can be generated based on the original URL, the first domain name, and the identifier of the target edge device corresponding to the cache location record of the requested resource file.
[0091] The identifier of the target edge device may include the IP address of the target edge device, and the method for generating the first URL may specifically include:
[0092] The IP address of the target edge device is encrypted to obtain an encryption prefix, and a first URL is generated based on the encryption prefix, the first domain name, and the original URL.
[0093] In this embodiment, the process of encrypting the IP address to obtain the encryption prefix has been described above and will not be repeated here. Since the database contains a cache location record of the requested resource file, it indicates that the resource file has been recently accessed and can be considered as the latest version of the resource file. Therefore, there is no need to verify the resource file. This application configures a first domain name for these resource files that do not require update verification. This first domain name is used to indicate that when the target edge device has cached the resource file locally, it does not need to update and verify the resource file when receiving a client redirection request. Instead, it can directly return the locally cached resource file to save the resource consumption of the edge device.
[0094] It should be noted that if the requested resource file is cached on multiple edge devices, one edge device can be selected as the target edge device based on the resource usage of the edge devices. This application does not impose any restrictions on this.
[0095] After generating the first URL, the first URL and status code 302 can be returned to the client so that the client knows that it needs to initiate a resource redirection request based on the IP address of the target edge device in the first URL after receiving status code 302.
[0096] The processing method of the target edge device after receiving the redirection request will be described in detail below, and will not be repeated here.
[0097] This concludes the description of step 203.
[0098] Step 204: Generate a second URL, which includes the original URL, a second domain name, and an identifier for the target edge device assigned to the resource file; return the second URL to the client so that the client sends a client redirection request to the target edge device based on the second URL; the second domain name is used to instruct the target edge device to update and verify the resource file to obtain the latest resource file if the target edge device has cached the resource file locally when it receives the client redirection request; wherein, the second domain name is different from the first domain name.
[0099] In this embodiment, step 204 is performed when it is determined that there is no cache location record of the requested resource file in the database. If it is determined that there is no cache location record of the requested resource file in the database, a second URL can be generated based on the original URL, the second domain name, and the identifier of the target edge device assigned to the resource file.
[0100] The identifier of the target edge device may include the IP address of the target edge device, and the method for generating the second URL may specifically include:
[0101] Select the target edge device from the edge devices connected to the scheduling server; encrypt the IP address of the target edge device to obtain an encryption prefix, and generate a second URL based on the encryption prefix, the second domain name, and the original URL.
[0102] In this embodiment, an edge device can be selected as the target edge device from among those that can be accessed by the client and have been registered in the scheduling server, based on the resource usage of the edge device. This application does not impose any restrictions on this.
[0103] Since the database does not contain a record of the cache location of the requested resource file, it indicates that the newly selected target edge device does not have a locally cached version of the resource file. Alternatively, the target edge device may have previously stored the resource file locally, but due to the resource file needing to be refreshed, or due to limited database capacity caused by prolonged inaccessibility, the resource file's cache location was deleted, or the database crashed, resulting in no record of the resource cache location in the database. In this case, it cannot be guaranteed that the resource file cached locally on the edge device is the latest resource file. Here, a second domain name can be configured for the resource file to update and verify it if the resource file is cached locally on the target edge device.
[0104] It should be noted that the second domain name here is a different domain name from the first domain name mentioned above. For example, the first domain name and the second domain name are different wildcard domain names; or, the first domain name and the second domain name are the same wildcard domain name with different prefixes.
[0105] As an example, the first domain and the second domain are different wildcard domains. A wildcard domain refers to domains with the same suffix. For example, for the same suffix *.AAA.com, resource files of domains with the suffix *.AAA.com, such as a.AAA.com and b.AAA.com, are all part of the same wildcard domain. Resource files with the same wildcard domain can be refreshed according to the resource refresh rules corresponding to that wildcard domain. Here, the first domain can be *.AAA.com, and the second domain can be *.BBB.com.
[0106] As an example, the first domain name can also be the same wildcard domain name with different prefixes. For example, for the same wildcard domain name *.AAA.com, the first domain name can be hit-xxx.AAA.com and the second domain name can be miss-xxx.AAA.com. This application does not impose any restrictions on this.
[0107] After generating the second URL, the second URL and status code 302 can be returned to the client so that the client knows that it needs to initiate a resource redirection request based on the IP address of the target edge device in the second URL after receiving status code 302.
[0108] The processing method of the target edge device after receiving the redirection request will be described in detail below, and will not be repeated here.
[0109] This concludes the description of step 204.
[0110] The above describes the process of refreshing a single resource file. As can be seen, according to the resource refresh method proposed in this application, when a resource file needs to be refreshed, it is only necessary to delete the cached location record in the database of the scheduling server. There is no need to perform a refresh operation on the edge device. Instead, the resource file is refreshed during the client's request for the resource file that needs to be refreshed, ensuring that the client obtains the latest resource file and reducing resource consumption on the edge device.
[0111] Considering that in practical applications, there may be situations where it is necessary to refresh an entire directory (i.e., refresh all resource files under a directory), the method for refreshing a single resource file described above can still be used (i.e., traverse the entire database entries and delete the cache location records of resource files belonging to the directory to be refreshed). However, this method may consume more database resources. This application also proposes two methods for refreshing an entire directory.
[0112] Specifically, the latest access time of each resource file can be further recorded in the database. This latest access time is the moment when the resource file was last accessed.
[0113] When a resource refresh instruction is received for any directory, the directory refresh rule for that directory to be refreshed is recorded in the database. The directory refresh rule includes the directory to be refreshed and the creation time of the directory refresh rule.
[0114] In this embodiment, when a resource refresh instruction is received for a directory to be refreshed, the directory refresh rule (i.e., the directory to be refreshed and the creation time of the directory refresh rule) of the directory to be refreshed can be recorded in the database. Unlike the single resource file refresh method described above, here it is only necessary to record the directory refresh rule of the directory to be refreshed. There is no need to traverse the database and delete all the cache location records of the resource files under the directory to be refreshed.
[0115] The first method for refreshing the directory is described below:
[0116] When a resource access request is received from a client, if the database is determined to contain a cache location record of the requested resource file based on the original URL carried in the resource access request sent by the client, the method further includes: detecting whether the latest access time of the resource file is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs;
[0117] If the latest access time of the resource file is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs, then the step of generating the second URL is executed;
[0118] If the latest access time of the resource file is not earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs, then continue to execute the step of generating the first URL.
[0119] In this embodiment, when a resource access request is received from a client, if it is determined from the original URL carried in the resource access request sent by the client that there is no cache location record of the requested resource file in the database, then the subsequent processing method is the same as the single resource file refresh method, and will not be described again here.
[0120] If the database is found to contain a cache location record of the requested resource file based on the original URL carried in the resource access request sent by the client, it is necessary to further determine which of the resource files in the database need to be refreshed since the cache location record of the resource file in the directory to be refreshed has not been deleted from the database.
[0121] In this embodiment, it can be further detected whether the latest access time of the resource file is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs.
[0122] If the latest access time of the resource file is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs, it means that the resource file has not been accessed since the creation of the directory refresh rule. In this case, the resource file can be considered not to be the latest resource file and needs to be updated and verified. Therefore, the above steps of generating the second URL can be performed on these resource files to update and verify the cached resource files in the edge device and return the latest resource file.
[0123] If the latest access time of the resource file is not earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs, it means that the resource file has been accessed after the creation of the directory refresh rule. As described above, the resource file has already been refreshed (updated and verified) on the first access after the creation of the directory refresh rule. At this time, the resource file can be considered as the latest resource file, and there is no need to update and verify the resource file again. Therefore, the steps of generating the first URL described above can be performed on these resource files to directly return the resource file cached in the edge device.
[0124] This concludes the description of the first directory refresh method.
[0125] The following describes another directory refresh method proposed in this application.
[0126] When a resource access request is received from a client, if the original URL carried in the resource access request belongs to any directory to be refreshed, a third URL is generated. The third URL includes the original URL, the creation time of the directory refresh rule of the directory to be refreshed, and the identifier of the target edge device corresponding to the resource file.
[0127] The third URL is returned to the client so that the client can send a client redirection request to the target edge device based on the third URL. The third URL is used to instruct the target edge device, after receiving the client redirection request, to obtain the latest resource file based on the creation time of the locally cached resource file and the creation time of the directory refresh rule, provided that the resource file is cached locally on the target edge device.
[0128] In this embodiment, when a resource access request is received from a client, it can be detected whether the original URL carried in the resource access request belongs to any directory to be refreshed. If so, a third URL can be generated based on the original URL, the creation time of the directory refresh rule of the directory to be refreshed, and the identifier of the target edge device corresponding to the resource file.
[0129] The method for generating the third URL is similar to that for generating the first and second URLs, and will not be repeated here. The target edge device identifier corresponding to the resource file can be the identifier of the target edge device corresponding to the resource file that has been recorded in the database, or it can be assigned to the resource file when the identifier of the target edge device corresponding to the resource file has not been recorded in the database. This application does not impose any restrictions on this.
[0130] After generating the third URL, the third URL and status code 302 can be returned to the client so that the client knows that it needs to initiate a resource redirection request based on the IP address of the target edge device in the third URL after receiving status code 302.
[0131] After receiving the redirection request, the target edge device can first check whether the resource file requested in the redirection request is cached locally on the edge device based on the original URL carried in the redirection request;
[0132] If not, the latest resource file can be directly obtained from the origin server based on the original URL and returned to the client, and the latest resource file can be cached in the target edge device.
[0133] If so, it is necessary to further determine whether the resource files cached locally on the edge device need to be updated and verified based on the creation time of the locally cached resource files and the creation time of the directory refresh rules.
[0134] In this embodiment, the edge device also locally records the creation time of each cached resource file. The creation time refers to the creation time of the current version of the resource file cached locally by the edge device. If the creation time of the locally cached resource file is earlier than the creation time of the directory refresh rule carried in the redirection request, it indicates that the resource file has not been accessed after the directory refresh rule was established. At this time, the resource file needs to be updated and verified to obtain the latest resource file and update the resource file and creation time recorded locally by the edge device.
[0135] If the creation time of the locally cached resource file is not earlier than the creation time of the directory refresh rule carried in the redirection request, it indicates that the resource file has been accessed through the edge device after the directory refresh rule was established. At this time, the resource file has been updated and verified, and the resource file cached locally by the edge device can be directly returned to the client.
[0136] This concludes the description of the second directory refresh method.
[0137] It's important to note that directory refresh rules are cleared after the maximum file cache duration. This maximum cache duration refers to the user-configured automatic file expiration time. For example, if the maximum cache duration for a configuration file is one month, then when the resource file is accessed again one month after its first access, it will automatically check if the file has expired. In this case, you can create a directory refresh rule that clears after the maximum duration mentioned above, because even without this rule, the resource files in that directory will automatically check with the origin server for updates the next time the client accesses it.
[0138] As can be seen, in the two directory refresh methods mentioned above, when refreshing the entire directory, it is not necessary to traverse the database and delete all resource file records in the directory, thus reducing resource consumption and processing time.
[0139] This concludes the discussion on... Figure 2 This describes the resource refresh method applied to the scheduling server.
[0140] This application eliminates the need for refresh operations on edge devices when resource files require updating. Instead, it deletes the corresponding cache location record for the resource file from the database associated with the scheduling server. Upon receiving a resource access request from a client, it sets a first domain name for resource files that do not require update verification, instructing the target edge device to directly return the resource file if it has it cached locally. For resource files requiring updating, it sets a second domain name, instructing the edge device to update and verify the resource file if it has it cached locally, thus obtaining the latest resource file. This approach eliminates the need for a unified refresh operation on edge devices while ensuring the client receives the latest resource file, reducing the performance overhead on edge devices.
[0141] Please refer to Figure 3 , Figure 3 This is a flowchart illustrating a resource refresh method for edge devices provided in an embodiment of this application.
[0142] like Figure 3 As shown, the method may include the following steps:
[0143] Step 301: Receive the client redirection request sent by the client.
[0144] In this embodiment, the client redirection request is sent to the edge device by the client after receiving the URL from the scheduling server. The process of the scheduling server sending the redirection request to the client is already described in the previous embodiment. Figure 2 The details are described in the text and will not be repeated here.
[0145] This concludes the description of step 301.
[0146] Step 302: Based on the original URL carried in the client redirection request, detect whether the edge device has cached the resource file requested by the client redirection request locally.
[0147] After receiving a client redirection request, the edge device can further detect whether the requested resource file is cached locally based on the original URL carried in the client redirection request.
[0148] If it is determined that the resource file is not cached locally on the edge device, proceed to step 303; if it is determined that the resource file is cached locally on the edge device, proceed to step 304.
[0149] Step 303: Obtain the latest resource file based on the original URL and return it to the client.
[0150] In this embodiment, if it is determined that the corresponding resource file is not cached locally on the edge device, the latest resource file can be directly obtained from the origin server according to the original URL and returned to the client. The resource file is then cached locally on the edge device. At the same time, the database will also record the cache location of the resource file.
[0151] It should be noted that if the corresponding resource file is not cached locally on the edge device, there is no need to further detect the domain name carried in the client's redirect request. In this case, the latest resource file can be directly obtained from the origin server based on the original URL and returned to the client.
[0152] Step 304: When the domain name carried in the client redirection request is the first domain name, the resource file already cached in the edge device is returned to the client; when the domain name carried in the client redirection request is the second domain name, the resource file cached locally in the edge device is updated and verified according to the original URL to return the latest resource file to the client.
[0153] Step 304 is performed if it is determined that the resource file is cached locally on the edge device based on the original URL carried in the client's redirect request.
[0154] After determining that the edge device has cached the resource file locally based on the original URL carried in the client redirect request, the domain name carried in the client redirect request can be further detected.
[0155] When the domain name carried in the client's redirect request is the first domain name, the first domain name is used to indicate that there is no need to verify the resource file cached locally on the edge device. In this case, it can be assumed that the resource file has been accessed recently, that is, the resource file is the latest resource file. At this time, there is no need to update and verify the resource file, and the resource file cached locally on the edge device can be directly returned to the client.
[0156] When the domain name carried in the client redirection request is the second domain name, the second domain name is used to indicate that the resource file cached locally on the edge device needs to be verified. At this time, it can be assumed that the resource file has been issued a refresh command, or that the resource file has not been accessed for a long time, causing the database to delete the corresponding cache location record when storage space is insufficient.
[0157] In either of the above scenarios, the resource files cached in the edge device cannot be guaranteed to be the latest resource files. In this case, the resource files cached locally on the edge device can be updated and verified based on the original URL to return the latest resource files to the client.
[0158] Specifically, methods for updating and validating resource files cached locally on the edge device based on the original URL to return the latest resource files to the client may include:
[0159] Send a file verification request with a verification request header to the origin server of the original URL; the verification request header carries the attribute information of the resource file requested by the resource retrieval request cached in the edge device. The file verification request is used to request the origin server to check whether the resource file has been updated based on the attribute information of the resource file.
[0160] If a first response is received from the origin server, indicating that the resource file has been updated, the updated resource file is downloaded from the origin server and returned to the client.
[0161] If a second response is received from the origin server, indicating that the resource file has not been updated, the cached resource file in the edge device is directly returned to the client.
[0162] In this embodiment, the attribute information includes at least one of the following: the timestamp, MD5 value, and version number of the resource file requested by the resource acquisition request.
[0163] As an example, the if-modified-since field can be included in the verification request header to prompt the origin server to check whether the resource file has been updated since it was cached to the edge device. The if-modified-since field will carry the latest update time of the resource file. The latest update time of the resource file on the origin server is compared with the latest update time of the resource file cached locally on the edge device to determine whether the resource file needs to be updated.
[0164] As an example, the If-None-Match field can also be included in the verification request header to prompt the origin server to check whether the resource file has been updated since it was cached to the edge device. The If-None-Match field here will carry the MD5 value of the resource file. The MD5 value of the latest resource file on the origin server is compared with the MD5 value of the resource file cached locally on the edge device to determine whether the resource file needs to be updated.
[0165] This concludes the description of step 304.
[0166] Similarly, when refreshing the entire directory, if the client-sent redirect request carries the creation time of the directory refresh rule of the directory to be refreshed to which the original URL belongs, then if the resource file requested by the client-sent redirect request is cached locally on the edge device, the creation time of the resource file requested by the client-sent redirect request cached locally on the edge device is compared with the creation time of the directory refresh rule.
[0167] If the resource file requested by the client redirection request in the local cache of the edge device was created earlier than the creation time of the directory refresh rule, the resource file is updated and verified according to the original URL to return the latest resource file to the client;
[0168] If the creation time of the resource file requested by the client redirection request cached locally on the edge device is not earlier than the creation time of the directory refresh rule, then the resource file requested by the client redirection request cached locally on the edge device will be directly returned to the client.
[0169] In this embodiment, the method for refreshing the entire directory has been described in detail above and will not be repeated here.
[0170] This concludes the discussion on... Figure 3 This describes a resource refresh method applied to edge devices.
[0171] The resource refresh method proposed in this application will be described in detail below through several specific embodiments.
[0172] First, you need to configure two different domain names on the CDN platform. For example, configure the wildcard domain "*.AA-miss.cn" and the wildcard domain "*.AA-hit.cn" on the CDN platform. "*.AA-hit.cn" corresponds to the first domain name mentioned above, and "*.AA-miss.cn" corresponds to the second domain name mentioned above.
[0173] Please refer to Figure 4 , Figure 4 This is a multi-party interaction diagram for a scenario where no resource file verification is required, provided in the embodiments of this application.
[0174] like Figure 4 As shown, the client initiates access to resource file 1 by sending a resource access request to the scheduling server. The resource access request carries the original URL of resource file 1, such as http: / / Z.com / vedio1.mp4.
[0175] After receiving the original URL of resource file 1, the scheduling server detects that there is a cache location record of the requested resource file (i.e., resource file 1) in the database. It can obtain the identifier of the edge device that cached resource file 1, and generate the first URL based on the edge device identifier, the first domain name and the original URL.
[0176] For example, if a database query reveals that the resource file exists on an edge device with IP address 183.131.106.101, it can be encrypted, for example, by concatenating the password "hello_world" and then performing base64 encryption to obtain a string such as "MTgzLjEzMS4xMDYuMTAxIGhlbGxvX3dvcmxk". Further, based on this string, the first domain name, and the original URL, a first URL can be generated: http: / / MTgzLjEzMS4xMDYuMTAxIGhlbGxvX3dvcmxk.AA-hit.cn / Z.com / vedio1.mp4.
[0177] The scheduling server returns the first URL and status code 302 to the client. After receiving status code 302, the client resolves the IP address of the target edge device from the first URL. Specifically, it decrypts the above MTgzLjEzMS4xMDYuMTAxIGhlbGxvX3dvcmxk.AA-hit.cn through an authoritative DNS server to obtain the IP address 183.131.106.101.
[0178] The client initiates a client redirection request to the corresponding edge device based on the resolved IP address. This client redirection request may include the first URL mentioned above, namely http: / / MTgzLjEzMS4xMDYuMTAxIGhlbGxvX3dvcmxk.AA-hit.cn / Z.com / vedio1.mp4.
[0179] After receiving a client's redirection request, the edge device can check whether resource file 1 is cached in its local cache based on the URL carried in the redirection request, and if resource file 1 is cached locally, it can directly return resource file 1 to the client.
[0180] Specifically, after receiving a client redirection request, the edge device can discard the first domain name and the preceding encrypted part of the URL carried in it to obtain the original URL, which is http: / / Z.com / vedio1.mp4. It can then determine whether resource file 1 is cached locally using this original URL. If it exists, it can retrieve the locally cached resource file 1 and return it to the client; otherwise, it can retrieve the latest resource file 1 from the origin server based on the original URL.
[0181] This concludes the discussion on... Figure 4 The description.
[0182] Please refer to Figure 5 , Figure 5 This is a multi-party interaction diagram for a scenario requiring resource file refresh, provided in the embodiments of this application.
[0183] like Figure 5 As shown, the client initiates access to resource file 2 by sending a resource access request to the scheduling server. The resource access request carries the original URL of resource file 2, such as http: / / Y.com / vedio1.mp4.
[0184] After receiving the original URL of resource file 2, the scheduling server detects that there is no cache location record for the requested resource file (i.e., resource file 2) in the database. It can assign an edge device identifier to resource file 2 and generate a second URL based on the edge device identifier, the second domain name, and the original URL.
[0185] For example, if an edge device with IP address 183.131.106.100 is assigned to resource file 2, it can be encrypted, for example, by concatenating the password "hello_world" and then performing base64 encryption to obtain a string such as "MTgzLjEzMS4xMDYuMTAwIGhlbGxvX3dvcmxk". Further, a second URL can be generated based on this string, the second domain name, and the original URL: MTgzLjEzMS4xMDYuMTAwIGhlbGxvX3dvcmxk.AA-miss.cn / Y.com / vedio1.mp4.
[0186] The scheduling server returns the second URL and status code 302 to the client. After receiving status code 302, the client resolves the IP address of the target edge device from the second URL. Specifically, it decrypts the above MTgzLjEzMS4xMDYuMTAxIGhlbGxvX3dvcmxk.AA-miss.cn through an authoritative DNS server to obtain the IP address 183.131.106.100.
[0187] The client initiates a client redirection request to the corresponding edge device based on the resolved IP address. This client redirection request may include the aforementioned second URL, namely MTgzLjEzMS4xMDYuMTAwIGhlbGxvX3dvcmxk.AA-miss.cn / Y.com / vedio1.mp4.
[0188] After receiving a client redirection request, the edge device can check whether resource file 2 is cached locally based on the URL carried in the redirection request. If resource file 2 is cached, the updated and verified latest resource file 2 will be returned to the client.
[0189] Specifically, after receiving a client redirection request, the edge device can discard the second domain name and the preceding encrypted part of the URL to obtain the original URL, http: / / Y.com / vedio1.mp4. If it is determined from the original URL that the resource file 2 is not cached locally, the device directly retrieves the latest resource file 2 from the origin server based on the original URL and returns it to the client. If it is determined from the original URL that the resource file 2 is cached locally, the device sends a request to the origin server with the request header "If-Modified-Since: Last Access Time", indicating that the origin server should check whether the resource file 2 has changed since the last access time. If it has, the device retrieves the latest resource file 2 and returns it to the client. If it has not been updated, the device returns the locally cached resource file 2 to the client.
[0190] This concludes the discussion on... Figure 5 The description.
[0191] Please refer to Figure 6 , Figure 6 This application provides a multi-party interaction diagram for a directory refresh scenario that does not require resource file verification.
[0192] like Figure 6 As shown, Figure 6 An interaction diagram of the first directory refresh method described above is provided.
[0193] The client initiates access to resource file 3 by sending a resource access request to the scheduling server, which includes the original URL of resource file 3.
[0194] After receiving the original URL of resource file 3, the scheduling server detects that there is a cache location record of the requested resource file (i.e., resource file 3) in the database, and further detects that the latest access time of resource file 3 is not earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs. Then, it obtains the identifier of the edge device that cached resource file 3, and generates the first URL based on the edge device identifier, the first domain name and the original URL.
[0195] The scheduling server returns the first URL and status code 302 to the client. After receiving status code 302, the client resolves the IP address of the target edge device from the first URL.
[0196] The client initiates a client redirection request to the corresponding edge device based on the resolved IP address. After receiving the client redirection request, the edge device can check whether the local cache has cached resource file 3 based on the URL carried in the redirection request. If the resource file 3 is cached locally, the edge device can directly return resource file 3 to the client.
[0197] This concludes the discussion on... Figure 6 The description.
[0198] Please refer to Figure 7 , Figure 7 This application provides a multi-party interaction diagram for a directory refresh scenario that requires resource file refresh.
[0199] like Figure 7 As shown, Figure 7 The interaction diagram for the first directory refresh method described above is also provided.
[0200] The client initiates access to resource file 4 by sending a resource access request to the scheduling server, which includes the original URL of resource file 4.
[0201] After receiving the original URL of resource file 4, the scheduling server detects that there is a cache location record of the requested resource file (i.e., resource file 4) in the database, and further detects that the latest access time of resource file 4 is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs. Then, it obtains the identifier of the edge device that cached resource file 4, and generates a second URL based on the edge device identifier, the second domain name and the original URL.
[0202] The scheduling server returns the second URL and status code 302 to the client. After receiving status code 302, the client resolves the IP address of the target edge device from the second URL.
[0203] The client initiates a client redirection request to the corresponding edge device based on the resolved IP address. After receiving the client redirection request, the edge device can check whether resource file 4 is cached locally based on the URL carried in the redirection request. If it is cached, the updated and verified latest resource file 4 will be returned to the client.
[0204] This concludes the discussion on... Figure 7 The description.
[0205] Please refer to Figure 8 , Figure 8 This is a multi-party interaction diagram for another directory refresh scenario that requires resource file refresh, provided in an embodiment of this application.
[0206] like Figure 8 As shown, Figure 8 An interaction diagram of the second directory refresh method described above is provided.
[0207] The client initiates access to resource file 5 by sending a resource access request to the scheduling server, which includes the original URL of resource file 5.
[0208] After receiving the original URL of resource file 5, the scheduling server detects that resource file 5 belongs to the resource file under the directory to be refreshed. It then obtains the identifier of the edge device that caches resource file 5 (if it exists in the database, it is obtained directly; if it does not exist, the target edge device is assigned), and generates a third URL based on the edge device identifier, the creation time of the directory refresh rule of the directory to be refreshed, and the original URL.
[0209] The scheduling server returns the third URL and status code 302 to the client. After receiving status code 302, the client resolves the IP address of the target edge device from the third URL.
[0210] The client initiates a client redirection request to the corresponding edge device based on the resolved IP address. After receiving the client redirection request, the edge device checks whether resource file 5 is cached locally. If not, it directly retrieves the latest resource file 5 from the origin server based on the original URL and returns it to the client.
[0211] If resource file 5 is already cached locally, it can be determined whether to update and verify the locally cached resource file 5 based on the creation time of the locally cached resource file 5 and the creation time of the directory refresh rule of the directory to be refreshed carried in the redirect request. If so, the resource file 5 is updated and verified according to the original URL, and the latest resource file is returned to the client. If not, the locally cached resource file 5 is returned to the client.
[0212] This concludes the discussion on... Figure 8 The description.
[0213] This concludes the description of the above embodiments.
[0214] Please refer to Figure 9 , Figure 9 This is a structural diagram of a resource refresh device applied to a scheduling server, as proposed in an embodiment of this application. Figure 9 As shown, the device may include a deletion unit 901, a determination unit 902, and an acquisition unit 903. Specifically, the device includes:
[0215] The deletion unit 901 is used to delete the cache location record corresponding to any resource file when a resource refresh instruction for any resource file is received, if the cache location record of the resource file exists in the database.
[0216] The determining unit 902 is used to determine, upon receiving a resource access request from a client, whether a cache location record of the requested resource file exists in the database based on the original URL carried in the resource access request sent by the client.
[0217] The acquisition unit 903 is used to generate a first URL if the condition is met. The first URL includes the original URL, a first domain name, and an identifier of the target edge device corresponding to the cache location record of the requested resource file. The first URL is returned to the client so that the client sends a client redirection request to the target edge device based on the first URL. The first domain name is used to indicate that when the target edge device receives the client redirection request, if the target edge device has cached the resource file locally, it will directly return the locally cached resource file.
[0218] If not, a second URL is generated, which includes the original URL, a second domain name, and an identifier for the target edge device assigned to the resource file. The second URL is returned to the client so that the client sends a client redirection request to the target edge device based on the second URL. The second domain name is used to instruct the target edge device to update and verify the resource file to obtain the latest resource file if the target edge device has cached the resource file locally when it receives the client redirection request. The second domain name is different from the first domain name.
[0219] Optionally, the identifier of the target edge device includes the IP address of the target edge device, and the acquisition unit 903 is specifically used for:
[0220] The IP address of the target edge device is encrypted to obtain an encryption prefix, and a first URL is generated based on the encryption prefix, the first domain name, and the original URL.
[0221] Generating the second URL includes:
[0222] Select the target edge device from the edge devices connected to the scheduling server; encrypt the IP address of the target edge device to obtain an encryption prefix, and generate a second URL based on the encryption prefix, the second domain name, and the original URL.
[0223] Optionally, the first domain name and the second domain name are different wildcard domain names; or, the first domain name and the second domain name are the same wildcard domain name with different prefixes.
[0224] Optionally, the database also records the latest access time of each resource file, and the acquisition unit 903 is also used for:
[0225] When a resource refresh instruction is received for any directory, the directory refresh rule for that directory to be refreshed is recorded in the database; the directory refresh rule includes the directory to be refreshed and the creation time of the directory refresh rule.
[0226] When a resource access request is received from a client, if the database is determined to have a cache location record of the requested resource file based on the original URL carried in the resource access request sent by the client, the acquisition unit 903 is further used to: detect whether the latest access time of the resource file is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs;
[0227] If the latest access time of the resource file is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs, then the step of generating the second URL is executed;
[0228] If the latest access time of the resource file is not earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs, then continue to execute the step of generating the first URL.
[0229] Optionally, the database also records the latest access time of each resource file, and the acquisition unit 903 is also used for:
[0230] When a resource refresh instruction is received for any directory, the directory refresh rule for that directory to be refreshed is recorded in the database; the directory refresh rule includes the directory to be refreshed and the creation time of the directory refresh rule.
[0231] When a resource access request is received from a client, if the original URL carried in the resource access request belongs to any directory to be refreshed, a third URL is generated. The third URL includes the original URL, the creation time of the directory refresh rule of the directory to be refreshed, and the identifier of the target edge device corresponding to the resource file.
[0232] The third URL is returned to the client so that the client can send a client redirection request to the target edge device based on the third URL. The third URL is used to instruct the target edge device, after receiving the client redirection request, to obtain the latest resource file based on the creation time of the locally cached resource file and the creation time of the directory refresh rule, provided that the resource file is cached locally on the target edge device.
[0233] This concludes the process. Figure 9 The description of the resource refresh device used in the scheduling server.
[0234] Please refer to Figure 10 , Figure 10 This is a structural diagram of a resource refresh device applied to an edge device according to an embodiment of this application. Figure 10As shown, the device may include a receiving unit 1001, a detection unit 1002, and a return unit 1003. Specifically, the device includes:
[0235] The receiving unit 1001 is used to receive a client redirection request sent by the client; the client redirection request is sent by the client to the edge device after receiving the URL sent by the scheduling server.
[0236] The detection unit 1002 is used to detect whether the edge device has cached the resource file requested by the client redirection request locally based on the original URL carried in the client redirection request;
[0237] The return unit 1003 is used to, if not, obtain the latest resource file according to the original URL and return it to the client; if yes, when the domain name carried in the client redirection request is the first domain name, return the resource file already cached in the edge device to the client; when the domain name carried in the client redirection request is the second domain name, update and verify the resource file locally cached in the edge device according to the original URL to return the latest resource file to the client.
[0238] Optionally, return unit 1003 is specifically used for:
[0239] Send a file verification request with a verification request header to the origin server of the original URL; the verification request header carries the attribute information of the resource file requested by the resource retrieval request cached in the edge device. The file verification request is used to request the origin server to check whether the resource file has been updated based on the attribute information of the resource file.
[0240] If a first response is received from the origin server, indicating that the resource file has been updated, the updated resource file is downloaded from the origin server and returned to the client.
[0241] If a second response is received from the origin server, indicating that the resource file has not been updated, the cached resource file in the edge device is directly returned to the client.
[0242] Optionally, the attribute information includes at least one of the following:
[0243] The resource acquisition request includes the timestamp, MD5 value, and version number of the resource file requested.
[0244] Optionally, the return unit 1003 is also used for:
[0245] If the client-sent redirect request carries the creation time of the directory refresh rule for the directory to be refreshed to which the original URL belongs, then if the resource file requested by the client-sent redirect request is cached locally on the edge device, the creation time of the resource file requested by the client-sent redirect request in the local cache on the edge device is compared with the creation time of the directory refresh rule.
[0246] If the resource file requested by the client redirection request in the local cache of the edge device was created earlier than the creation time of the directory refresh rule, the resource file is updated and verified according to the original URL to return the latest resource file to the client;
[0247] If the creation time of the resource file requested by the client redirection request cached locally on the edge device is not earlier than the creation time of the directory refresh rule, then the resource file requested by the client redirection request cached locally on the edge device will be directly returned to the client.
[0248] This concludes the discussion on... Figure 10 Description of a resource refresh device applied to edge devices.
[0249] Please refer to Figure 11 , Figure 11 This is a schematic diagram of a resource refresh system architecture provided in an embodiment of this application.
[0250] like Figure 11 As shown, the resource refresh system may include:
[0251] The scheduling server, communicating with at least one client and at least one edge device, is used to perform tasks such as... Figure 2 The method shown;
[0252] The client communicates with the scheduling server and at least one edge device, and is used to send resource access requests to the scheduling server and, after receiving the URL returned by the scheduling server, send a client redirection request to the corresponding edge device based on the URL.
[0253] Edge devices are used to perform tasks such as Figure 3 The method shown.
[0254] In this embodiment, the resource refresh method executed by the scheduling server and the edge device has been described in detail above and will not be repeated here.
[0255] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A resource refresh method, characterized in that, This method is applied to a scheduling server, and the method includes: When a resource refresh instruction is received for any resource file, if a cache location record for that resource file exists in the database, the corresponding cache location record for that resource file will be deleted. Upon receiving a resource access request from a client, the system determines whether a cache location record of the requested resource file exists in the database based on the original URL carried in the resource access request. If so, a first URL is generated, which includes the original URL, a first domain name, and an identifier of the target edge device corresponding to the cache location record of the requested resource file; the first URL is returned to the client so that the client sends a client redirection request to the target edge device based on the first URL; the first domain name is used to indicate that when the target edge device receives the client redirection request, if the target edge device has cached the resource file locally, it will directly return the resource file. If not, a second URL is generated, which includes the original URL, a second domain name, and an identifier for the target edge device assigned to the resource file; the second URL is returned to the client so that the client sends a client redirection request to the target edge device based on the second URL; the second domain name is used to indicate that when the target edge device receives the client redirection request, if the target edge device has the resource file cached locally, it should update and verify the resource file to obtain the latest resource file; wherein, the second domain name is different from the first domain name.
2. The method according to claim 1, characterized in that, The identifier of the target edge device includes the IP address of the target edge device, and the generation of the first URL includes: The IP address of the target edge device is encrypted to obtain an encryption prefix, and the first URL is generated based on the encryption prefix, the first domain name, and the original URL; The generation of the second URL includes: Select a target edge device from the edge devices connected to the scheduling server; encrypt the IP address of the target edge device to obtain an encryption prefix, and generate the second URL based on the encryption prefix, the second domain name, and the original URL.
3. The method according to claim 1, characterized in that, The first domain name and the second domain name are different wildcard domain names; or, the first domain name and the second domain name are the same wildcard domain name with different prefix identifiers.
4. The method according to claim 1, characterized in that, The database also records the latest access time of each resource file, and the method further includes: Upon receiving a resource refresh instruction for any directory, the directory refresh rule for the directory to be refreshed is recorded in the database; the directory refresh rule includes the directory to be refreshed and the creation time of the directory refresh rule. When a resource access request is received from a client, if the database is determined to contain a cache location record of the requested resource file based on the original URL carried in the resource access request sent by the client, the method further includes: detecting whether the latest access time of the resource file is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs; If the latest access time of the resource file is earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs, then the step of generating the second URL is executed; If the latest access time of the resource file is not earlier than the creation time of the directory refresh rule of the directory to which the resource file belongs, then continue to execute the step of generating the first URL.
5. The method according to claim 1, characterized in that, The database also records the latest access time of each resource file, and the method further includes: Upon receiving a resource refresh instruction for any directory, the directory refresh rule for the directory to be refreshed is recorded in the database; the directory refresh rule includes the directory to be refreshed and the creation time of the directory refresh rule. When a resource access request is received from a client, if the original URL carried in the resource access request belongs to any directory to be refreshed, a third URL is generated. The third URL includes the original URL, the creation time of the directory refresh rule of the directory to be refreshed, and the identifier of the target edge device corresponding to the resource file. The third URL is returned to the client so that the client sends a client redirection request to the target edge device based on the third URL; the third URL is used to instruct the target edge device, after receiving the client redirection request, to obtain the latest resource file based on the creation time of the locally cached resource file and the creation time of the directory refresh rule, if the resource file is cached locally on the target edge device.
6. A resource refresh method, characterized in that, This method is applied to edge devices, and the method includes: Receive a client redirection request sent by the client; the client redirection request is sent by the client to the edge device after receiving the URL sent by the scheduling server; Based on the original URL carried in the client redirection request, detect whether the edge device has cached the resource file requested by the client redirection request locally; If not, the latest resource file is obtained based on the original URL and returned to the client; If so, when the domain name carried in the client redirection request is the first domain name, the resource file already cached in the edge device is returned to the client; when the domain name carried in the client redirection request is the second domain name, the resource file cached locally in the edge device is updated and verified according to the original URL to return the latest resource file to the client.
7. The method according to claim 6, characterized in that, The step of updating and verifying the resource file locally cached on the edge device based on the original URL to return the latest resource file to the client includes: Send a file verification request carrying a verification request header to the origin server of the original URL; the verification request header carries the attribute information of the resource file requested by the resource acquisition request cached in the edge device, and the file verification request is used to request the origin server to check whether the resource file has been updated based on the attribute information of the resource file; If a first response is received from the origin server, indicating that the resource file has been updated, the updated resource file is downloaded from the origin server and returned to the client. If a second response is received from the origin server, indicating that the resource file has not been updated, then the resource file cached in the edge device is directly returned to the client.
8. The method according to claim 7, characterized in that, The attribute information includes at least one of the following: The resource acquisition request requests the timestamp, MD5 value, and version number of the resource file.
9. The method according to claim 6, characterized in that, The method also includes: If the client redirection request sent by the client carries the creation time of the directory refresh rule of the directory to be refreshed to which the original URL belongs, then if the resource file requested by the client redirection request is cached locally on the edge device, the creation time of the resource file requested by the client redirection request cached locally on the edge device is compared with the creation time of the directory refresh rule. If the creation time of the resource file requested by the client redirection request cached locally on the edge device is earlier than the creation time of the directory refresh rule, then the resource file is updated and verified according to the original URL to return the latest resource file to the client; If the creation time of the resource file requested by the client redirection request and cached locally on the edge device is not earlier than the creation time of the directory refresh rule, then the resource file requested by the client redirection request and cached locally on the edge device will be directly returned to the client.
10. A resource refresh system, characterized in that, include: A scheduling server, communicatively connected to at least one client and at least one edge device, is used to perform the method as described in any one of claims 1 to 5; The client is communicatively connected to the scheduling server and at least one edge device, and is used to send a resource access request to the scheduling server, and after receiving the URL returned by the scheduling server, send a client redirection request to the corresponding edge device based on the URL. An edge device for performing the method as described in any one of claims 6 to 9.
Citation Information
Patent Citations
Method and system for updating client cache
CN111475180A
Cache refreshing method and device, equipment and storage medium
CN116095172A