Resource Request Method, Server, and Client
By querying the latest modification dates of target resources and associated resources on the server side and generating corresponding query information, the problem of slow resource loading speed in the existing technology is solved, and a faster and more efficient resource loading process is achieved.
Patent Information
- Application Number
- CN202010268442.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-08
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2040-04-08
AI Technical Summary
In the prior art, when loading resources, the client needs to send a request to the server separately to query whether the first modification date of the resource is equal to the latest modification date, resulting in slow loading of the resource and occupying a large number of broadband resources.
When the server receives the client's target resource loading request, it uses the target resource's identification to query its latest modification date, and also queries the latest modification date of the associated resource. Based on the comparison results, generate resource loading information and query information of associated resources and feed it back to the client to determine whether resources can be loaded directly from the local cache.
Through a resource loading request, the target resource can be loaded normally, and the latest modification date of the associated resource that needs to be loaded can be queryed in the future, reducing the number of resource requests and improving the resource loading speed.
Smart Images

Figure CN113495788B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of resource requests, and particularly to a method for requesting resources, a server, and a client. Background Art
[0002] Many current clients cache certain resources locally, so that resources can be loaded from the local cache, and it is not necessary to request all resources from the server, which can bring beneficial effects such as faster resource loading.
[0003] However, when the client loads resources, it needs to load the latest resources. Therefore, when the client needs to load the target resource in the local cache, it needs to send a request to the server that includes the first modification time of the target resource, where the first modification time is the modification time of the resource cached locally by the client. After receiving the request, the server will compare whether the first modification time of the received target resource is equal to the latest modification time of the target resource stored by itself. If the first modification time of the target resource is not equal to the latest modification time of the target resource, it means that the target resource has been modified. At this time, the server will feedback the latest target resource and the latest modification time of the target resource to the client; if the first modification time of the target resource is equal to the latest modification time of the target resource, it means that the target resource cached by the client is the latest. Therefore, the server feedbacks the target response information to the client, triggering the client to directly load the target resource from the local cache.
[0004] However, for the existing method, the client needs to send a separate request to the server for each resource to query whether the first modification date and the latest modification date of the resource are equal to determine whether the resource can be directly loaded from the local cache, which makes the resource loading speed slower. And because the number of resource requests is also large, it will occupy a large amount of broadband resources, so it will also affect the resource loading speed. Summary of the Invention
[0005] Based on the above deficiencies of the prior art, the present invention provides a method for requesting resources, a server, and a client to solve the problem of too slow loading speed of the existing resource request method.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] In the first aspect of this application, a method for requesting resources is provided, which is applied to a server. The method includes:
[0008] Obtain a resource loading request for a target resource sent by a client; wherein, the resource loading request carries at least the identifier of the target resource and the modification date of the target resource;
[0009] Using the identifier of the target resource, query to obtain the latest modification date of the target resource and the latest modification date of the associated resources of the target resource; wherein, the associated resources of the target resource are the resources that need to be loaded subsequently after loading the target resource.
[0010] Generate resource loading information according to the comparison result between the modification date of the target resource and the latest modification date of the target resource, and generate query information for the associated resources according to the latest modification date of the associated resources; wherein, if the modification date of the target resource is not equal to the latest modification date of the target resource, the resource loading information includes the target resource and its latest modification date; if the modification date of the target resource is equal to the latest modification date of the target resource, the resource loading information includes target response information, and the target response information is used to trigger the client to load the target resource from the local cache; the query information for the associated resources is the basis for the client to determine whether to directly load the associated resources from the local cache when loading the associated resources subsequently.
[0011] Feedback the resource loading information and the query information for the associated resources to the client.
[0012] Optionally, in the above resource request method, the querying the latest modification date of the associated resources of the target resource includes:
[0013] Extract the resource addresses of each of the associated resources from the resource loading request.
[0014] Respectively find the associated resources according to the resource addresses of the associated resources, and obtain the latest modification date of the associated resources.
[0015] Optionally, in the above resource request method, the querying the latest modification date of the associated resources of the target resource includes:
[0016] Determine the identifiers of each of the associated resources of the target resource according to the identifier of the target resource.
[0017] Respectively obtain the latest modification date of the associated resources according to the identifiers of each of the associated resources.
[0018] Optionally, in the above resource request method, the generating the query result for the associated resources according to the latest modification date of the associated resources of the target resource includes:
[0019] Respectively compare the modification date of each of the associated resources with the latest modification date; wherein, the modification date of each of the associated resources is included in the resource loading request.
[0020] Determine the associated resources among each of the said associated resources whose modification date is equal to the latest modification date as unmodified resources;
[0021] Add the identifiers of each of the said unmodified resources to the first target field to obtain the query information; wherein, the query information is used to trigger the client to generate a loading identifier for the associated resources corresponding to the identifiers of each of the said unmodified resources; the loading identifier is used to indicate to the client to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
[0022] Optionally, in the above method for requesting resources, generating the query result of the associated resources according to the latest modification date of the associated resources of the target resource includes:
[0023] Add the identifier and the latest modification date of each of the said associated resources to the second target field to obtain the query information;
[0024] Wherein: the query information is used to trigger the client to compare the latest modification date of each of the associated resources in the query information with the modification date of the associated resources in the local cache respectively, and generate a loading identifier for each of the associated resources whose compared modification date is not equal to the latest modification date; the loading identifier is used to indicate to the client to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
[0025] A second aspect of the present application provides another method for requesting resources, which is applied to a client, and the method includes:
[0026] Send a resource loading request for a target resource to the server; wherein, the resource loading request carries at least the identifier of the target resource and the modification date of the target resource;
[0027] Receive the resource loading information and the query information of the associated resources fed back by the server; wherein: when the server compares that the modification date of the target resource is not equal to the latest modification date of the target resource, the resource loading information includes the target resource and its latest modification date; when comparing that the modification date of the target resource is equal to the latest modification date of the target resource, the resource loading information includes target response information, and the target response information is used to trigger the client to load the target resource from the local cache; the query information of the associated resources is generated by the server according to the latest modification date of the associated resources and is used for the client to determine whether to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
[0028] Optionally, in the above resource request method, after receiving the resource loading information and the query information of the associated resources fed back by the server, the method further includes:
[0029] Generating a loading identifier for each associated resource corresponding to the identifier of the unmodified resource in the first target field of the query information; wherein the loading identifier is used to instruct the client to directly load the associated resource from the local cache when the client loads the associated resource; the modification date of the unmodified resource is equal to the latest modification date, and is determined by the server by comparing the modification dates of the respective associated resources included in the resource loading request with the latest modification date; the latest modification date of the associated resource is obtained by the server according to the resource address of the associated resource in the resource loading request.
[0030] Optionally, in the above resource request method, after receiving the resource loading information and the query information of the associated resources fed back by the server, the method further includes:
[0031] Comparing the modification dates of the respective associated resources in the query information with the modification dates of the associated resources in the local cache, and generating a loading identifier for each of the associated resources whose modification dates are found to be equal to the latest modification date; wherein the loading identifier is used to instruct the client to directly load the associated resource from the local cache when the client subsequently loads the associated resource.
[0032] The third aspect of the present application provides a server, including:
[0033] An obtaining unit, configured to obtain a resource loading request of a target resource sent by a client; wherein the resource loading request carries at least the identifier of the target resource and the modification date of the target resource;
[0034] A query unit, configured to use the identifier of the target resource to query the latest modification date of the target resource and the latest modification date of the associated resource of the target resource; wherein the associated resource of the target resource is a resource that needs to be loaded subsequently after loading the target resource;
[0035] A first generation unit for generating resource loading information based on the comparison result between the modification date of the target resource and the latest modification date of the target resource; wherein, if the modification date of the target resource is not equal to the latest modification date of the target resource, the resource loading information includes the target resource and its latest modification date; if the modification date of the target resource is equal to the latest modification date of the target resource, the resource loading information includes target response information for triggering the client to load the target resource from the local cache.
[0036] A second generation unit for generating query information of the associated resource according to the latest modification date of the associated resource; wherein, the query information of the associated resource is the basis for the client to determine whether to directly load the associated resource from the local cache when loading the associated resource subsequently.
[0037] A sending unit for feeding back the resource loading information and the query information of the associated resource to the client.
[0038] Optionally, in the above server, when the query unit executes the query of the latest modification date of the associated resource of the target resource, it is used for:
[0039] Extracting the resource addresses of the respective associated resources from the resource loading request, respectively finding the associated resources according to the resource addresses of the associated resources, and obtaining the latest modification dates of the associated resources.
[0040] Optionally, in the above server, when the query unit executes the query of the latest modification date of the associated resource of the target resource, it is used for:
[0041] Determining the identifiers of the respective associated resources of the target resource according to the identifier of the target resource, and respectively obtaining the latest modification dates of the associated resources according to the identifiers of the respective associated resources.
[0042] Optionally, in the above server, the second generation unit includes:
[0043] A comparison unit for respectively comparing the modification dates of the respective associated resources with the latest modification dates; wherein, the modification dates of the respective associated resources are included in the resource loading request.
[0044] A determination unit for determining the associated resources whose modification dates are equal to the latest modification dates among the respective associated resources as unmodified resources.
[0045] A first adding unit, configured to add the identifiers of the unmodified resources to a first target field to obtain the query information; wherein the query information is used to trigger the client to generate a loading identifier for the associated resources corresponding to the identifiers of the unmodified resources; the loading identifier is used to instruct the client to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
[0046] Optionally, in the above-mentioned server, the second generating unit includes:
[0047] A second adding unit, configured to add the identifiers of the associated resources and the latest modification date to a second target field to obtain the query information;
[0048] wherein: the query information is used to trigger the client to compare the latest modification date of each of the associated resources in the query information with the modification date of the associated resources cached locally, and generate a loading identifier for each of the associated resources whose compared modification date is equal to the latest modification date; the loading identifier is used to instruct the client to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
[0049] A fourth aspect of the present application provides a client, including:
[0050] A sending unit, configured to send a resource loading request for a target resource to the server; wherein the resource loading request carries at least the identifier of the target resource and the modification date of the target resource;
[0051] A receiving unit, configured to receive the resource loading information and the query information of the associated resources fed back by the server; wherein: when the server compares that the modification date of the target resource is not equal to the latest modification date of the target resource, the resource loading information includes the target resource and its latest modification date; when it is compared that the modification date of the target resource is equal to the latest modification date of the target resource, the resource loading information includes a target response information, and the target response information is used to trigger the client to load the target resource from the local cache; the query information of the associated resources is generated by the server according to the latest modification date of the associated resources and is used for the client to determine whether to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
[0052] Optionally, in the above-mentioned client, it further includes:
[0053] A first generation unit for generating a loading identifier for the associated resource corresponding to the identifier of each unmodified resource in the first target field of the query information; wherein the loading identifier is used to instruct the client to directly load the associated resource from the local cache when the client loads the associated resource; the modification date of the unmodified resource is equal to the latest modification date, and is determined by the server by comparing the modification dates of the respective associated resources included in the resource loading request with the latest modification date; the latest modification date of the associated resource is obtained by the server according to the resource address of the associated resource in the resource loading request.
[0054] Optionally, in the above client, it further includes:
[0055] A second generation unit for comparing the modification dates of the respective associated resources in the query information with the modification dates of the associated resources in the local cache, and generating a loading identifier for each of the associated resources whose modification dates are compared to be equal to the latest modification date; wherein the loading identifier is used to instruct the client to directly load the associated resource from the local cache when the client subsequently loads the associated resource.
[0056] In the resource request method provided by the present application, after the server obtains the resource loading request of the target resource sent by the client, while querying the latest modification date of the target resource using the identifier of the target resource, it will further query the latest modification date of the associated resource of the target resource. Wherein, the associated resource of the target resource is the resource that needs to be loaded subsequently after loading the target resource. It is no longer the case that only one resource is queried for one resource request. Then, according to the comparison result between the modification date of the target resource and the latest modification date of the target resource, resource loading information is generated, and according to the latest modification date of the associated resource, query information of the associated resource is generated, and the resource loading information of the target resource and the query information of the associated resource are fed back to the client. Wherein, the query information of the associated resource is the basis for the client to determine whether to directly load the associated resource from the local cache when subsequently loading the associated resource. Thus, by sending one resource loading request, while normally requesting to load the target resource, it is also possible to query the associated resources to be loaded subsequently to determine whether the client can load the associated resource from the local cache. When it is possible to directly load the associated resource from the local cache, then when loading the associated resource, there is no need to send a resource loading request to the server again, and the associated resource can be quickly loaded directly from the local cache, thereby also reducing the number of resource requests, and thus effectively improving the resource loading speed. Description of the Drawings
[0057] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only the embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on the provided drawings.
[0058] Figure 1 A flowchart of a method for requesting a resource provided by an embodiment of the present application;
[0059] Figure 2 A flowchart of another method for requesting a resource provided by another embodiment of the present application;
[0060] Figure 3 A flowchart of a method for querying the latest modification date of associated resources provided by another embodiment of the present application;
[0061] Figure 4 A flowchart of another method for requesting a resource provided by yet another embodiment of the present application;
[0062] Figure 5 A schematic structural diagram of a server provided by another embodiment of the present application;
[0063] Figure 6 A schematic structural diagram of a second generation unit provided by another embodiment of the present application;
[0064] Figure 7 A schematic structural diagram of a client provided by another embodiment of the present application. Detailed implementation manners
[0065] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.
[0066] In this application, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.
[0067] An embodiment of this application provides a method for requesting resources, as Figure 1 shown, specifically including:
[0068] S101. The client sends a resource loading request for a target resource to the server, and the resource loading request carries at least the identifier of the target resource and the modification date of the target resource.
[0069] Among them, the target resource is a resource stored in the local cache of the client. The modification date of the target resource is also stored in the local cache of the client and is obtained from the server when requesting the target resource.
[0070] S102. The server uses the identifier of the target resource to query the latest modification date of the target resource and the latest modification date of the associated resources of the target resource.
[0071] Among them, the associated resources of the target resource are the resources that need to be loaded subsequently after loading the target resource, that is, the associated resources of the target resource are the resources that the client needs to load immediately after loading the target resource. For example, when loading a web page, after loading the main page of the web page, that is, after loading the hypertext transfer page file of the web page, the pictures, script files, cascading style sheets, etc. of the web page that need to be loaded subsequently are the associated resources of the main page of the web page. Therefore, there is an inherent association relationship between the target resource and its associated resources, and a target resource can have multiple associated resources.
[0072] It should be noted that the target resources are also stored in the server, and the management personnel can update the target resources. After the resources are modified, the server will record the date when the resources are modified this time, that is, record the latest modification date of the resources. The modification date of the resources stored in the client is the modification date of the resources recorded by the server when the resources were last requested. However, the resources may have changed after the last request. Since the client needs to load the latest resources when loading the resources, it is determined whether the resources have been modified by comparing whether the modification date stored in the client is the same as the latest date of the resources in the server.
[0073] Specifically, the server first uses the identifier of the target resource to query the latest modification date of the target resource, so as to determine whether the target resource needs to be returned to the client subsequently. Moreover, in this embodiment of the present invention, when querying the latest modification date of the target resource, the latest modification date of the associated resources of the target resource can be further queried. That is to say, in the resource request method provided by the embodiment of the present application, while normally requesting the target resource, the function of querying the associated resources is additionally added. Since there is an association relationship between the target resource and its associated resources, multiple associated resources associated with the target resource can be determined according to the association relationship, and thus the latest modification date of each associated resource can be further queried.
[0074] S103. The server generates resource loading information according to the comparison result between the modification date of the target resource and the latest modification date of the target resource, and generates query information of the associated resources according to the latest modification date of the associated resources.
[0075] Among them, if it is compared that the modification date of the target resource is not equal to the latest modification date of the target resource, the generated resource loading information includes the target resource and its latest modification date, that is, the target resource stored in the client is not the latest, so the server needs to return the target resource stored in the server and the latest modification date of the target resource to the client.
[0076] If it is compared that the modification date of the target resource is equal to the latest modification date of the target resource, the target resource has not been modified. Therefore, the generated resource loading information only includes the target response information, where the target response information is specifically the 304 status code. After receiving the target response information, the client loads the target resource from the local cache.
[0077] Optionally, according to the latest modification date of the associated resource, query information of the associated resource can be generated. It can be directly encapsulating the latest modification date as the query information. After feeding it back to the client, the client can compare the modification date of the local associated resource with the latest modification date of the received associated resource. Thus, when loading the target resource, it can directly determine whether the local associated resource has changed, and then determine whether the associated resource can be directly loaded from the local cache without having to send a request to the server to determine. Of course, the client can also add the modification date of the target resource to the loading request of the target resource, so that the server compares the modification date of the associated resource with its latest modification date. And the comparison result is encapsulated as the query information of the associated resource. The client determines whether the associated resource can be directly loaded from the local cache according to the comparison results corresponding to each associated resource. Therefore, the query information of the associated resource is the basis for the client to determine whether to directly load the associated resource from the local cache when loading the associated resource subsequently.
[0078] S104. The server feeds back resource loading information and query information of the associated resource to the client.
[0079] Correspondingly, the client receives the resource loading information and query information of the associated resource fed back by the server.
[0080] In the resource request method provided by the embodiment of the present application, after the server obtains the resource loading request of the target resource sent by the client, while querying the latest modification date of the target resource by using the identifier of the target resource, it will further query the latest modification date of the associated resource of the target resource. Among them, the associated resource of the target resource is the resource that needs to be loaded subsequently after loading the target resource. It is no longer that one resource request only queries one resource. Then, according to the comparison result between the modification date of the target resource and the latest modification date of the target resource, resource loading information is generated, and according to the latest modification date of the associated resource, query information of the associated resource is generated, and the resource loading information of the target resource and the query information of the associated resource are fed back to the client. Among them, the query information of the associated resource is the basis for the client to determine whether to directly load the associated resource from the local cache when loading the associated resource subsequently. Thus, by sending one resource loading request, while normally requesting to load the target resource, it can also query the associated resource to be loaded subsequently to determine whether the client can load the associated resource from the local cache. When the associated resource can be directly loaded from the local cache, there is no need to send a resource loading request to the server again when loading the associated resource, and the associated resource can be directly and quickly loaded from the local cache, thus reducing the number of resource requests, and effectively improving the resource loading speed.
[0081] Another resource request method provided by another embodiment of the present application is as Figure 2As shown in the figure, it includes:
[0082] Extract the resource addresses of each of the associated resources from the resource loading request.
[0083] S201. A resource loading request for a target resource sent by a client to a server, where the resource loading request carries at least an identifier of the target resource, a modification date of the target resource, and a modification time of an associated resource of the target resource.
[0084] Among them, the associated resource of the target resource is a resource that needs to be loaded subsequently after the target resource is loaded.
[0085] S202. The server uses the identifier of the target resource to query and obtain the latest modification date of the target resource.
[0086] Among them, the specific implementation manner of step S202 can be correspondingly referred to step S102 in the above method embodiment, and will not be elaborated here.
[0087] It should be noted that the execution order of step 202 in the embodiment of the present application is only an optional manner, and is not limited to being executed before step S203.
[0088] Optionally, in the embodiment of the present application, in addition to normally carrying the identifier of the target resource and the modification date of the target resource, the resource loading request may also carry the resource addresses and modification dates of each associated resource of the target resource. Therefore, the specific manner of querying the latest modification date of the associated resource of the target resource in the embodiment of the present application is as shown in steps S203 and S204.
[0089] S203. The server extracts the resource addresses of each associated resource from the resource loading request.
[0090] That is to say, the client actively initiates a query for the associated resource by adding information about the associated resource of the target resource to the resource loading request of the target resource. Specifically, the client can determine information about multiple associated resources of the target resource based on the association relationship between the target resource and its associated resources, and add this information to the resource loading request of the target resource.
[0091] Optionally, corresponding fields can be added to the target resource, and information about the associated resources can be added to the fields. For example, three fields, "X-URL-NUM", "X-URL-XXX", and "X-LAST-XXX", are added to the resource loading request. Among them, "X-URL-NUM" represents the number of associated resources to be queried, and "NUM" in this field represents the number of associated resources to be queried. "X-URL-XXX" is the address of each associated resource, where "XXX" in this field is the identifier of the associated resource, which can specifically be the number assigned by the client to each associated resource. "X-LAST-XXX" is the last modification date of each associated resource, and similarly, "XXX" in this field is the identifier of the associated resource.
[0092] Therefore, after receiving the resource loading request, the resource addresses of each associated resource can be extracted from the corresponding fields.
[0093] S204. The server respectively locates the associated resources according to the resource addresses of the associated resources and obtains the latest modification date of the associated resources.
[0094] S205. The server generates resource loading information based on the comparison result between the modification date of the target resource and the latest modification date of the target resource.
[0095] Among them, if the modification date of the target resource is not equal to the latest modification date of the target resource, the generated resource loading information includes the latest target resource and its latest modification date; if it is compared that the modification date of the target resource is equal to the latest modification date of the target resource, resource loading information including target response information is generated. Among them, the target response information is used to trigger the client to load the target resource from the local cache.
[0096] It should be noted that in the embodiments of the present application, the execution order of step S205 is only one of the optional ways. The specific execution order of step S205 can be executed as long as it is after the execution of step S202 and before the execution of step S209, and is not limited to being executed after the execution of step S204.
[0097] S206. The server respectively compares the modification dates of each associated resource with the latest modification date.
[0098] Among them, the modification dates of each associated resource are included in the resource loading request.
[0099] Since the resource loading request contains the modification dates of the associated resources, the server compares the modification dates of each associated resource with the latest modification date to determine the associated resources whose modification dates are equal to the latest modification date from each associated resource.
[0100] S207. The server determines the associated resources among all the associated resources whose modification date is equal to the latest modification date as unmodified resources.
[0101] S208. The server adds the identifiers of all the unmodified resources to the first target field to obtain query information.
[0102] That is to say, in the embodiments of the present application, only the identifiers of the associated resources whose modification date is equal to the latest modification date are fed back to the client, that is, the identifiers of the associated resources that can be directly loaded from the local cache are fed back to the client. For the associated resources whose identifiers are not fed back, it means that they cannot be directly obtained from the local cache. Among them, the first target resource is a field newly added in the feedback information for adding the identifiers of the unmodified resources. For example, the newly added first target field can be "X-304-LIST: X1, X2…", where X1 and X2 are the identifiers of the unmodified resources.
[0103] Of course, this is only one optional way, and the feedback method for the query results is not limited to this one. For example, the identifiers of all the queried associated resources can also be fed back to the client, but the identifiers of the two types of associated resources with different comparison results need to be distinguished. Specifically, the identifiers of the two types of associated resources can be fed back through two different fields respectively. Or only the identifiers of the modified associated resources are added to the first target field and returned to the client. At this time, step S207 can be to determine the associated resources among all the associated resources whose modification date is not equal to the latest modification date as modified resources. Since the resource loading request sent by the client contains the information of all the associated resources, after receiving the first target field, the client can also determine the modified resources according to the identifiers of the unmodified associated resources in the first target field.
[0104] S209. The server feeds back the resource loading information and the query information of the associated resources to the client.
[0105] S210. The client generates loading identifiers for the associated resources corresponding to the identifiers of all the unmodified resources in the first target field of the query information.
[0106] Among them, the loading identifier is used to indicate the client to directly load the associated resource from the local cache when the client subsequently loads the associated resource.
[0107] Therefore, in the embodiments of the present application, when the client needs to load a resource, it will first determine whether the resource has a loading identifier. If it is determined that the resource has a loading identifier, the resource is directly loaded from the local cache.
[0108] It should be noted that while the client generates a loading identifier for the associated resources corresponding to the identifier of the unmodified resource, it can also mark the associated resources that do not belong to the associated resources of the modified resource among the associated resources of the target resource. For example, the unmodified resource can be marked with a loading identifier "1", and the modified associated resource can be marked with an identifier "0". Therefore, when the client needs to load the associated resources of the target resource, it detects the identifier of the associated resource. If it is "1", it directly loads from the local cache; if it is "0", it needs to send a resource loading request to the server to implement resource loading. Of course, it is also possible to only generate the corresponding target identifier for the modified associated resource. Correspondingly, when the client loads the associated resource, if the associated resource does not have a target identifier, it directly loads from the local, and if there is a target identifier, it requests the server to load. These all fall within the protection scope of the present invention.
[0109] It should also be noted that in the embodiments of the present application, the resource loading request may not carry the resource address of the associated resource of the target resource. Since the resource loading request does not carry the resource address of the associated resource, it is impossible to obtain the latest modification date of the associated resource through steps S301 and S302. Therefore, steps S203 and 204 of the embodiments of the present application are correspondingly replaced with steps S301 and S302 as shown in Figure 3 follows, specifically including:
[0110] S301. The server determines the identifiers of the respective associated resources of the target resource according to the identifier of the target resource.
[0111] Since the resource loading request does not include the resource address of the associated resource, the server needs to determine the identifiers of the respective associated resources associated with the target resource according to the identifier of the target resource to determine the associated resources to be queried.
[0112] S302. The server respectively obtains the latest modification date of the associated resource according to the identifier of each associated resource.
[0113] The resource request method provided by the embodiment of the present application. After the server obtains the resource loading request of the target resource sent by the client, while querying the latest modification date of the target resource using the identifier of the target resource, it will further query the latest modification date of the associated resource of the target resource. Here, the associated resource of the target resource is the resource that needs to be loaded subsequently after loading the target resource. It is no longer the case that only one resource is queried for one resource request. Then, according to the comparison result between the modification date of the target resource and the latest modification date of the target resource, resource loading information is generated, and according to the comparison result between the latest modification date of the associated resource and the modification date of the associated resource, query information of the associated resource is generated and fed back to the client. The client marks the associated resource with a loading identifier according to the query result, so as to determine whether to directly load the associated resource from the local cache based on the loading identifier when loading the associated resource subsequently. Thus, by sending one resource loading request, while normally loading the target resource, it also queries the associated resources to be loaded subsequently to determine whether the client can load the associated resources from the local cache. When the associated resources can be directly loaded from the local cache, there is no need to send a resource loading request to the server again when loading the associated resources, and the associated resources can be quickly loaded directly from the local cache, thereby also reducing the number of resource requests, and effectively improving the resource loading speed.
[0114] Another resource request method provided by another embodiment of the present application is as Figure 4 shown, and specifically includes:
[0115] S401. The client sends a resource loading request for the target resource to the server, and the resource loading request carries at least the identifier of the target resource and the modification date of the target resource.
[0116] It should be noted that the specific implementation manner of step S401 can be correspondingly referred to step S101 in the above method embodiment, and will not be elaborated here.
[0117] S402. The server queries the latest modification date of the target resource using the identifier of the target resource.
[0118] Among them, the specific implementation manner of step S402 can be correspondingly referred to step S102 in the above method embodiment, and will not be elaborated here.
[0119] It should be noted that the execution order of step 402 in the embodiment of the present application is only an optional manner and is not limited to being executed before step S403.
[0120] Optionally, in the embodiments of the present application, the resource loading request does not carry the resource addresses and modification dates of the associated resources of the target resource. Therefore, in the embodiments of the present application, by performing step S403 and step S404, the latest modification dates of the associated resources of the target resource are queried.
[0121] S403. The server determines the identifiers of the associated resources of the target resource according to the identifier of the target resource.
[0122] That is to say, the client only normally sends a resource loading request for the target resource to the server, and after receiving the resource loading request, the server actively queries the associated resources of the target resource.
[0123] Among them, the specific implementation manner of step S403 can be correspondingly referred to step S301 in the above method embodiment, and will not be elaborated here.
[0124] S404. The server respectively obtains the latest modification dates of the associated resources according to the identifiers of the associated resources.
[0125] Among them, the specific implementation manner of step S404 can be correspondingly referred to step S302 in the above method embodiment, and will not be elaborated here.
[0126] S405. The server generates resource loading information according to the comparison result between the modification date of the target resource and the latest modification date of the target resource.
[0127] Among them, if the modification date of the target resource is not equal to the latest modification date of the target resource, the generated resource loading information includes the latest target resource and its latest modification date; if it is compared that the modification date of the target resource is equal to the latest modification date of the target resource, resource loading information including target response information is generated. Among them, the target response information is used to trigger the client to load the target resource from the local cache.
[0128] It should be noted that in the embodiments of the present application, the execution order of step S405 is only one optional way. The specific execution order of step S405 can be executed as long as it is after the execution of step S402 and before the execution of step S407, and is not limited to being executed after the execution of step S404.
[0129] S406. The server adds the identifiers and the latest modification dates of the associated resources to the second target field to obtain query information.
[0130] Since the client does not send the modification date of the associated resource to the server, the server cannot compare the modification date of the associated resource with its latest modification date and directly feedback the comparison result to the client. Therefore, the server can only feedback the latest modification date of each queried associated resource to the client, and then the client makes the comparison.
[0131] S407. The server feedbacks the resource loading information and the query information of the associated resource to the client.
[0132] S408. The client compares the latest modification date of each associated resource in the query information with the modification date of the corresponding associated resource cached locally, and generates a loading identifier for each associated resource where the modification date is equal to the latest modification date.
[0133] Among them, the loading identifier is used to indicate the client to directly load the associated resource from the local cache when the client subsequently loads the associated resource. It should be noted that for the specific usage process of the loading identifier, reference can be made to the usage process of the loading identifier mentioned in step S210 of the above method embodiment, which will not be elaborated here.
[0134] Similarly, step S408 is only one of the optional ways. Other identifiers different from the loading identifier can also be generated for the associated resources where the modification date is not equal to the latest modification date. Or target identifiers can be generated only for the associated resources where the modification date is not equal to the latest modification date, and the target identifier is used to indicate the client to send a resource loading request to the server to load the associated resource. The specific implementation manners of these two ways can be correspondingly referred to step S210 of the above method embodiment, which will not be elaborated here.
[0135] It should also be noted that in the embodiment of the present application, the resource loading request may also include the resource address of the associated resource of the target resource. Therefore, the latest modification date of the associated resource can be queried through the resource address of the associated resource of the target resource. So at this time, step S403 and step S404 in the embodiment of the present application can be correspondingly replaced with Figure 2 steps S203 and S204 shown as follows to query the latest modification date of the associated resource through the resource address of the associated resource of the target resource.
[0136] The resource request method provided by the embodiments of the present application is as follows. After the server obtains the resource loading request of the target resource sent by the client, while querying the latest modification date of the target resource using the identifier of the target resource, it will further query the latest modification date of the associated resources of the target resource. Among them, the associated resources of the target resource are the resources that need to be loaded subsequently after loading the target resource. It is no longer the case that only one resource is queried for one resource request. Then, according to the comparison result between the modification date of the target resource and the latest modification date of the target resource, resource loading information is generated, and the latest modification date of the associated resource is used as the query information of the associated resource, and the resource loading information and the query information are fed back to the client. The client can determine whether to directly load the associated resource from the local cache based on the comparison between the modification date and the latest modification date of the associated resource. Thus, by sending one resource loading request, while normally requesting to load the target resource, it is also possible to query the subsequent associated resources to be loaded to determine whether the client can load the associated resource from the local cache. When the associated resource can be directly loaded from the local cache, there is no need to send a resource loading request to the server when loading the associated resource, and the associated resource can be quickly loaded directly from the local cache, thereby also reducing the number of resource requests, and thus effectively improving the resource loading speed.
[0137] Another embodiment of the present application provides a server, as Figure 5 shown, including:
[0138] An obtaining unit 501, configured to obtain a resource loading request of a target resource sent by a client.
[0139] Among them, the resource loading request carries at least the identifier of the target resource and the modification date of the target resource.
[0140] A query unit 502, configured to query the latest modification date of the target resource and the latest modification date of the associated resources of the target resource by using the identifier of the target resource.
[0141] Among them, the associated resources of the target resource are the resources that need to be loaded subsequently after loading the target resource.
[0142] A first generating unit 503, configured to generate resource loading information according to the comparison result between the modification date of the target resource and the latest modification date of the target resource.
[0143] Among them, if the modification date of the target resource is not equal to the latest modification date of the target resource, the resource loading information includes the target resource and its latest modification date; if the modification date of the target resource is equal to the latest modification date of the target resource, the resource loading information includes target response information, and the target response information is used to trigger the client to load the target resource from the local cache.
[0144] A second generation unit 504 is configured to generate query information for associated resources according to the latest modification date of the associated resources.
[0145] The query information for the associated resources is the basis for the client to determine whether to directly load the associated resources from the local cache when loading the associated resources subsequently.
[0146] A sending unit 505 is configured to feedback resource loading information and query information for associated resources to the client.
[0147] It should be noted that the specific working processes of the above units in the embodiments of the present application may refer to steps S101 to S104 in the above method embodiments correspondingly, which will not be elaborated here.
[0148] Optionally, in another embodiment of the present application, when the query unit in the server executes querying the latest modification date of the associated resources of the target resource, it is configured to:
[0149] Extract the resource addresses of each associated resource from the resource loading request, and respectively find the associated resources according to the resource addresses of the associated resources, and obtain the latest modification date of the associated resources.
[0150] Optionally, in another embodiment of the present application, when the query unit in the server executes querying the latest modification date of the associated resources of the target resource, it is configured to:
[0151] Determine the identifiers of each associated resource of the target resource according to the identifier of the target resource, and respectively obtain the latest modification date of the associated resources according to the identifiers of each associated resource.
[0152] Optionally, in another embodiment of the present application, the second generation unit 504, as Figure 6 shown, includes:
[0153] A comparison unit 601 is configured to respectively compare the modification dates of each associated resource with the latest modification date.
[0154] The modification date of each associated resource is included in the resource loading request.
[0155] A determination unit 602 is configured to determine the associated resources whose modification dates are equal to the latest modification date among each associated resource as unmodified resources.
[0156] A first addition unit 603 is configured to add the identifiers of each unmodified resource to the first target field to obtain the query information.
[0157] Among them, the query information is used to trigger the client to generate a loading identifier for the associated resources corresponding to the identifiers of each unmodified resource. The loading identifier is used to indicate to the client to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
[0158] It should be noted that the specific working processes of the above units in the embodiments of the present application can be correspondingly referred to the steps S206 to S208 in the above method embodiments, and will not be elaborated here.
[0159] Optionally, in another embodiment of the present application, the second generation unit 504 includes:
[0160] The second addition unit is used to add the identifiers and the latest modification dates of each associated resource to the second target field to obtain the query information.
[0161] Among them: the query information is used to trigger the client to respectively compare the latest modification dates of each associated resource in the query information with the modification dates of the associated resources in the local cache, and generate a loading identifier for each associated resource whose comparison result shows that the modification date is equal to the latest modification date; the loading identifier is used to indicate to the client to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
[0162] Another embodiment of the present application provides a client, as Figure 7 shown, including:
[0163] The sending unit 701 is used to send a resource loading request for the target resource to the server. Among them, the resource loading request carries at least the identifier of the target resource and the modification date of the target resource.
[0164] The receiving unit 702 is used to receive the resource loading information and the query information of the associated resources fed back by the server.
[0165] Among them: when the server compares and finds that the modification date of the target resource is not equal to the latest modification date of the target resource, the resource loading information includes the target resource and its latest modification date; when it is compared that the modification date of the target resource is equal to the latest modification date of the target resource, the resource loading information includes the target response information, and the target response information is used to trigger the client to load the target resource from the local cache. The query information of the associated resources is generated by the server according to the latest modification dates of the associated resources, and is used for the client to determine whether to directly load the associated resources from the local cache when subsequently loading the associated resources.
[0166] It should be noted that the specific working processes of the above units in the embodiments of the present application can be correspondingly referred to the steps S101 to S104 in the above method embodiments, and will not be elaborated here.
[0167] Optionally, the client in another embodiment of the present application further includes:
[0168] A first generating unit, configured to generate a loading identifier for an associated resource corresponding to the identifier of each unmodified resource in the first target field of the query information.
[0169] Wherein, the loading identifier is used to instruct the client to directly load the associated resource from the local cache when the client loads the associated resource; the modification date of the unmodified resource is equal to the latest modification date, and is determined by the server by comparing the modification dates of the respective associated resources included in the resource loading request with the latest modification date; the latest modification date of the associated resource is obtained by the server according to the resource address of the associated resource in the resource loading request.
[0170] Optionally, the client in another embodiment of the present application further includes:
[0171] A second generating unit, configured to compare the modification dates of the respective associated resources in the query information with the modification dates of the associated resources in the local cache, and generate a loading identifier for each associated resource whose compared modification date is equal to the latest modification date.
[0172] Wherein, the loading identifier is used to instruct the client to directly load the associated resource from the local cache when the client subsequently loads the associated resource.
[0173] Those skilled in the art can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods for each specific application to implement the described functions, but such implementation should not be considered to exceed the scope of the present invention.
[0174] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but will be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for requesting a resource, characterized in that, Applied to a server, the method includes: Obtain a resource loading request for a target resource sent by a client; wherein, the resource loading request carries at least an identifier of the target resource and a modification date of the target resource; Use the identifier of the target resource to query the latest modification date of the target resource and the latest modification date of the associated resources of the target resource; wherein, the associated resources of the target resource are resources that need to be loaded subsequently after loading the target resource; Generate resource loading information according to the comparison result between the modification date of the target resource and the latest modification date of the target resource, and generate query information for the associated resources according to the latest modification date of the associated resources; wherein, if the modification date of the target resource is not equal to the latest modification date of the target resource, the resource loading information includes the target resource and its latest modification date; if the modification date of the target resource is equal to the latest modification date of the target resource, the resource loading information includes target response information, and the target response information is used to trigger the client to load the target resource from the local cache; the query information for the associated resources is the basis for the client to determine whether to directly load the associated resources from the local cache when loading the associated resources subsequently; Feedback the resource loading information and the query information for the associated resources to the client.
2. The method according to claim 1, characterized in that, The querying the latest modification date of the associated resources of the target resource includes: Extract the resource addresses of the respective associated resources from the resource loading request; Respectively find the associated resources according to the resource addresses of the associated resources and obtain the latest modification date of the associated resources.
3. The method according to claim 1, wherein The querying the latest modification date of the associated resources of the target resource includes: Determine the identifiers of the respective associated resources of the target resource according to the identifier of the target resource; Respectively obtain the latest modification date of the associated resources according to the identifiers of the respective associated resources.
4. The method according to any one of claims 1 to 3, characterized in that, The generating the query result for the associated resources according to the latest modification date of the associated resources of the target resource includes: Respectively compare the modification dates of the respective associated resources with the latest modification date; wherein, the modification dates of the respective associated resources are included in the resource loading request; Determine the associated resources whose modification dates are equal to the latest modification date among the respective associated resources as unmodified resources; Add the identifiers of the respective unmodified resources to a first target field to obtain the query information; wherein, the query information is used to trigger the client to generate a loading identifier for the associated resources corresponding to the identifiers of the respective unmodified resources; the loading identifier is used to instruct the client to directly load the associated resources from the local cache when the client loads the associated resources subsequently.
5. The method according to any one of claims 1 to 3, characterized in that, The generating the query result for the associated resources according to the latest modification date of the associated resources of the target resource includes: Add the identifiers and the latest modification dates of the respective associated resources to a second target field to obtain the query information; Wherein: the query information is used to trigger the client to respectively compare the latest modification dates of the respective associated resources in the query information with the modification dates of the associated resources cached locally, and generate a loading identifier for each of the associated resources whose modification dates are equal to the latest modification dates; the loading identifier is used to instruct the client to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
6. A method for requesting a resource, characterized in that, Applied to a client, the method includes: Sending a resource loading request for a target resource to a server; wherein, the resource loading request carries at least the identifier of the target resource and the modification date of the target resource; Receiving resource loading information and query information of associated resources fed back by the server; wherein: when the server compares and finds that the modification date of the target resource is not equal to the latest modification date of the target resource, the resource loading information includes the target resource and its latest modification date; when the server compares and finds that the modification date of the target resource is equal to the latest modification date of the target resource, the resource loading information includes target response information, and the target response information is used to trigger the client to load the target resource from the local cache; the query information of the associated resources is generated by the server according to the latest modification dates of the associated resources and is used for the client to determine whether to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
7. The method according to claim 6, wherein After receiving the resource loading information and the query information of the associated resources fed back by the server, it further includes: Generating a loading identifier for the associated resources corresponding to the identifiers of the unmodified resources in the first target field of the query information; wherein, the loading identifier is used to instruct the client to directly load the associated resources from the local cache when the client loads the associated resources; the modification dates of the unmodified resources are equal to the latest modification dates, and are determined by the server by respectively comparing the modification dates of the respective associated resources included in the resource loading request with the latest modification dates; the latest modification dates of the associated resources are found by the server according to the resource addresses of the associated resources in the resource loading request.
8. The method according to claim 6, characterized in that, After receiving the resource loading information and the query information of the associated resources fed back by the server, it further includes: Comparing the modification dates of the respective associated resources in the query information with the modification dates of the associated resources cached locally, and generating a loading identifier for each of the associated resources whose modification dates are equal to the latest modification dates; wherein, the loading identifier is used to instruct the client to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
9. A server, characterized in that, Includes: An obtaining unit, configured to obtain a resource loading request for a target resource sent by a client; wherein, the resource loading request carries at least the identifier of the target resource and the modification date of the target resource; A query unit, configured to query the latest modification date of the target resource and the latest modification date of the associated resource of the target resource by using the identifier of the target resource; wherein, the associated resource of the target resource is the resource that needs to be loaded subsequently after loading the target resource; A first generation unit, configured to generate resource loading information according to the comparison result between the modification date of the target resource and the latest modification date of the target resource; wherein, if the modification date of the target resource is not equal to the latest modification date of the target resource, the resource loading information includes the target resource and its latest modification date; if the modification date of the target resource is equal to the latest modification date of the target resource, the resource loading information includes target response information, and the target response information is used to trigger the client to load the target resource from the local cache; A second generation unit, configured to generate query information for the associated resource according to the latest modification date of the associated resource; wherein, the query information for the associated resource is the basis for the client to determine whether to directly load the associated resource from the local cache when subsequently loading the associated resource; A sending unit, configured to feedback the resource loading information and the query information for the associated resource to the client.
10. The server according to claim 9, wherein When the query unit executes the query of the latest modification date of the associated resource of the target resource, it is configured to: Extract the resource addresses of the respective associated resources from the resource loading request, and respectively find the associated resources according to the resource addresses of the associated resources, and obtain the latest modification dates of the associated resources.
11. The server according to claim 9, wherein When the query unit executes the query of the latest modification date of the associated resource of the target resource, it is configured to: Determine the identifiers of the respective associated resources of the target resource according to the identifier of the target resource, and respectively obtain the latest modification dates of the associated resources according to the identifiers of the respective associated resources.
12. The server according to any one of claims 9 to 11, characterized in that, The second generation unit includes: A comparison unit, configured to respectively compare the modification dates of the respective associated resources with the latest modification dates; wherein, the modification dates of the respective associated resources are included in the resource loading request; A determination unit, configured to determine the associated resources that belong to the case where the modification date is equal to the latest modification date among the respective associated resources as unmodified resources; A first addition unit, configured to add the identifiers of the respective unmodified resources to a first target field to obtain the query information; wherein, the query information is used to trigger the client to generate a loading identifier for the associated resource corresponding to the identifier of each unmodified resource; the loading identifier is used to indicate the client to directly load the associated resource from the local cache when the client subsequently loads the associated resource.
13. The server according to any one of claims 9 to 11, characterized in that, The second generation unit includes: A second addition unit, configured to add the identifiers and the latest modification dates of the respective associated resources to a second target field to obtain the query information; Wherein: the query information is used to trigger the client to respectively compare the latest modification dates of the respective associated resources in the query information with the modification dates of the associated resources cached locally, and generate a loading identifier for each of the associated resources whose modification dates are equal to the latest modification dates; the loading identifier is used to instruct the client to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
14. A client, characterized in that, Including: A sending unit, configured to send a resource loading request for a target resource to the server; wherein, the resource loading request carries at least the identifier of the target resource and the modification date of the target resource; A receiving unit, configured to receive the resource loading information and the query information of the associated resources fed back by the server; wherein: when the server compares that the modification date of the target resource is not equal to the latest modification date of the target resource, the resource loading information includes the target resource and its latest modification date; when it is compared that the modification date of the target resource is equal to the latest modification date of the target resource, the resource loading information includes a target response message, and the target response message is used to trigger the client to load the target resource from the local cache; the query information of the associated resources is generated by the server according to the latest modification dates of the associated resources and is used for the client to determine whether to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
15. The client according to claim 14, wherein Further including: A first generating unit, configured to generate a loading identifier for the associated resources corresponding to the identifiers of the unmodified resources in the first target field of the query information; wherein, the loading identifier is used to instruct the client to directly load the associated resources from the local cache when the client loads the associated resources; the modification dates of the unmodified resources are equal to the latest modification dates, and are determined by the server by respectively comparing the modification dates of the respective associated resources included in the resource loading request with the latest modification dates; the latest modification dates of the associated resources are found by the server according to the resource addresses of the associated resources in the resource loading request.
16. The client according to claim 14, characterized in that Further including: A second generating unit, configured to compare the modification dates of the respective associated resources in the query information with the modification dates of the associated resources cached locally, and generate a loading identifier for each of the associated resources whose modification dates are equal to the latest modification dates; wherein, the loading identifier is used to instruct the client to directly load the associated resources from the local cache when the client subsequently loads the associated resources.
Citation Information
Patent Citations
Webpage resource cache control method, device and system
CN102456035A
Resource updating method and device
CN108337280A