CN114531489A - Request response method and device - Google Patents

Request response method and device Download PDF

Info

Publication number
CN114531489A
CN114531489A CN202210044525.XA CN202210044525A CN114531489A CN 114531489 A CN114531489 A CN 114531489A CN 202210044525 A CN202210044525 A CN 202210044525A CN 114531489 A CN114531489 A CN 114531489A
Authority
CN
China
Prior art keywords
cache
response data
network request
response
real
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210044525.XA
Other languages
Chinese (zh)
Inventor
李春
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202210044525.XA priority Critical patent/CN114531489A/en
Publication of CN114531489A publication Critical patent/CN114531489A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Abstract

The method firstly responds to a network request of a browser and searches a cache strategy corresponding to the network request; the caching strategy comprises caching timeliness of caching response data corresponding to the network request; then, determining whether the cache response data is valid or not based on the cache aging, the cache timestamp of the cache response data and the current timestamp; and finally, feeding back the cache response data to the browser under the condition that the cache response data are effective. According to the method and the device, different caching strategies can be configured according to the characteristics of different network requests, so that the caching response data of different network requests have different caching timeliness, the reliability of the caching response data is improved, new data of the requests are not required to be obtained from the server every time, and the data communication frequency is reduced.

Description

Request response method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a request response method and apparatus.
Background
In order to improve the access speed of the web page and reduce the pressure of the server, the browser usually adopts a caching scheme, and common caching schemes include a hypertext Transfer Protocol (HTTP) standard caching scheme and an intra-web caching scheme. The HTTP standard caching scheme mainly comprises a strong cache and a negotiation cache, wherein the strong cache can set caching timeliness for caching data, the negotiation cache is negotiated with a server through a client, and the server judges whether the cache is available according to timeliness and resources. The caching scheme in the webpage comprises a snapshot cache and a timing cache, and can be suitable for the situation that entity files do not exist in the requested data, but the snapshot cache still needs to request new data every time, and the timing cache is difficult to judge the updating time of the data, so that the expired data is easy to take.
Disclosure of Invention
The embodiment of the disclosure at least provides a request response method and a request response device.
In a first aspect, an embodiment of the present disclosure provides a request response method, including:
responding to a network request of a browser, and searching a cache strategy corresponding to the network request; the caching strategy comprises caching timeliness of caching response data corresponding to the network request;
determining whether the cache response data is valid based on the cache aging, the cache timestamp of the cache response data, and the current timestamp;
and feeding back the cache response data to the browser under the condition that the cache response data are effective.
In an optional embodiment, the method further comprises:
initializing the cache stability description information of the network request under the condition that the cache strategy is not found;
and determining a cache strategy corresponding to the network request based on the cache stability description information of the network request.
In an optional embodiment, the method further comprises:
and under the condition that the cache response data is invalid, requesting the real-time response data corresponding to the network request from a server, and feeding back the real-time response data to the browser.
In an optional embodiment, the method further comprises:
after the cache response data are fed back to the browser or after preset updating conditions are met, requesting real-time response data corresponding to the network request from a server;
and if the real-time response data is inconsistent with the cache response data, feeding back the real-time response data to the browser.
In an optional embodiment, the method further comprises:
and updating the cache response data by using the real-time response data, and updating the cache time stamp of the cache response data.
In an optional embodiment, the method further comprises:
obtaining attribute information of historical response data fed back by the server when the network request is responded at the previous time;
generating a replacement cache policy of the network request based on the attribute information of the historical response data, the attribute information of the real-time response data and the cache stability description information of the network request;
and updating the cache strategy corresponding to the network request by using the replacement cache strategy.
In an optional embodiment, the generating a replacement caching policy for the network request based on the attribute information of the historical response data, the attribute information of the real-time response data, and the caching stability description information of the network request includes:
determining a consistency comparison result of the historical response data and the real-time response data based on the attribute information of the historical response data and the attribute information of the real-time response data;
updating the cache stability description information of the network request based on the consistency comparison result of the determined historical response data and the real-time response data;
and generating a replacement caching strategy of the network request based on the updated stability description information.
In an optional embodiment, the updating the cache stability description information of the network request based on the determined consistency comparison result between the historical response data and the real-time response data includes:
if the historical response data is consistent with the real-time response data, updating the response stabilization times and the response stabilization duration in the cache stability description information;
and updating the response stability grade based on the updated response stability times and response stability duration and the response stability grade in the stability description information before updating.
In an optional embodiment, the updating the cache stability description information of the network request based on the determined consistency comparison result between the historical response data and the real-time response data includes:
and if the historical response data is inconsistent with the real-time response data, initializing the response stabilization times, the response stabilization duration and the response stabilization grade in the cache stability description information.
In an optional implementation manner, the generating a replacement caching policy of the network request based on the updated stability description information includes:
and searching a target cache strategy matched with the response stability grade in the stability description information, and taking the searched target cache strategy as the replacement cache strategy.
In a second aspect, an embodiment of the present disclosure further provides a request response apparatus, including:
the searching module is used for responding to a network request of a browser and searching a cache strategy corresponding to the network request; the caching strategy comprises caching time efficiency of caching response data corresponding to the network request;
a determining module, configured to determine whether the cache response data is valid based on the cache aging, the cache timestamp of the cache response data, and the current timestamp;
and the response module is used for feeding back the cache response data to the browser under the condition that the cache response data is valid.
In an optional implementation manner, the lookup module is further configured to:
initializing the cache stability description information of the network request under the condition that the cache strategy is not found;
and determining a cache strategy corresponding to the network request based on the cache stability description information of the network request.
In an optional implementation, the response module is further configured to:
and under the condition that the cache response data is invalid, requesting the real-time response data corresponding to the network request from a server, and feeding back the real-time response data to the browser.
In an optional implementation, the response module is further configured to:
after the cache response data are fed back to the browser or after preset updating conditions are met, requesting real-time response data corresponding to the network request from a server;
and if the real-time response data is inconsistent with the cache response data, feeding back the real-time response data to the browser.
In an optional implementation, the response module is further configured to:
and updating the cache response data by using the real-time response data, and updating the cache time stamp of the cache response data.
In an optional implementation, the response module is further configured to:
obtaining attribute information of historical response data fed back by the server when the network request is responded at the previous time;
generating a replacement cache policy of the network request based on the attribute information of the historical response data, the attribute information of the real-time response data and the cache stability description information of the network request;
and updating the cache strategy corresponding to the network request by using the replacement cache strategy.
In an optional embodiment, when generating the replacement caching policy of the network request based on the attribute information of the historical response data, the attribute information of the real-time response data, and the caching stability description information of the network request, the response module is configured to:
determining a consistency comparison result of the historical response data and the real-time response data based on the attribute information of the historical response data and the attribute information of the real-time response data;
updating the cache stability description information of the network request based on the consistency comparison result of the determined historical response data and the real-time response data;
and generating a replacement caching strategy of the network request based on the updated stability description information.
In an optional embodiment, when updating the cache stability description information of the network request based on the determined consistency comparison result between the historical response data and the real-time response data, the response module is configured to:
if the historical response data is consistent with the real-time response data, updating the response stabilization times and the response stabilization duration in the cache stability description information;
and updating the response stability grade based on the updated response stability times and response stability duration and the response stability grade in the stability description information before updating.
In an optional embodiment, the response module updates the cache stability description information of the network request based on a comparison result of the determined consistency between the historical response data and the real-time response data. For:
and if the historical response data is inconsistent with the real-time response data, initializing the response stabilization times, the response stabilization duration and the response stabilization grade in the cache stability description information.
In an optional embodiment, when generating the replacement caching policy of the network request based on the updated stability description information, the response module is configured to:
and searching a target cache strategy matched with the response stability grade in the stability description information, and taking the searched target cache strategy as the replacement cache strategy.
In a third aspect, an embodiment of the present disclosure further provides an electronic device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the electronic device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect described above, or any possible implementation of the first aspect.
In a fourth aspect, this disclosed embodiment also provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps in the first aspect described above or any one of the possible implementation manners of the first aspect.
The request response method and the request response device provided by the embodiment of the disclosure firstly respond to a network request of a browser and search a cache strategy corresponding to the network request; the caching strategy comprises caching timeliness of caching response data corresponding to the network request; then, determining whether the cache response data is effective or not based on the cache aging, the cache timestamp of the cache response data and the current timestamp; and finally, feeding back the cache response data to the browser under the condition that the cache response data are effective. According to the method and the device, whether the cache response data are effective or not is judged through the cache strategy deployed for the network request, the cache time stamp of the cache response data and the current time stamp, different cache strategies can be configured according to the characteristics of different network requests, so that the cache response data of different network requests have different cache timeliness, the reliability of the cache response data is improved, new data of the request are not required to be acquired from a server every time, and the data communication frequency is reduced.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required to be used in the embodiments will be briefly described below, and the drawings herein are incorporated into and constitute a part of this specification, and show the embodiments consistent with the present disclosure and together with the description serve to explain the technical solutions of the present disclosure. It is appreciated that the following drawings depict only certain embodiments of the disclosure and are therefore not to be considered limiting of its scope, for those skilled in the art will be able to derive additional related drawings therefrom without the benefit of the inventive faculty.
Fig. 1 shows a flowchart of a request response method provided by an embodiment of the present disclosure;
FIG. 2 is a flow chart illustrating another request response method provided by embodiments of the present disclosure;
FIG. 3 shows a flowchart of the steps provided by an embodiment of the present disclosure to generate a cache score;
FIG. 4 is a schematic diagram of a request response device provided by an embodiment of the disclosure;
fig. 5 shows a schematic diagram of an electronic device provided by an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, as generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making any creative effort, shall fall within the protection scope of the disclosure.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The term "and/or" herein merely describes an associative relationship, meaning that three relationships may exist, e.g., a and/or B, may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
Research shows that the browser strong cache mode can set expiration time for network resources to control cache updating, the operation process is simple, but not flexible enough, and if the network resources are updated within the expiration time, updated contents cannot be displayed; the negotiation cache generally comprises two types, one type needs to judge whether the resource is updated according to the time when the server updates the resource last and the time when the browser acquires the resource last, the other type needs to calculate the characteristic value of the resource, the latest characteristic value of the resource is compared with the characteristic value returned last time, although the calculation resource is accurate, the consumed calculation resource is more; for the webpage caching scheme, a snapshot cache establishes a data snapshot after data is successfully requested each time, the snapshot data is loaded first when the next request is made, meanwhile, the latest data is requested, if the latest data is consistent, the cache is directly used, if the latest data is inconsistent, the latest data is returned, and network communication is required to be performed for each request; the timing cache is similar to the strong cache, and caches the data of a certain interface for a certain period of time, so that the local data is directly returned without initiating a request in the cache, and the timeliness of the data is difficult to guarantee.
Based on the research, the disclosure provides a request response method, which judges whether cache response data are valid or not by a cache policy deployed for a network request, a cache timestamp of cache response data and a current timestamp, and can configure different cache policies according to characteristics of different network requests, so that the cache response data of different network requests have different cache timeliness, thereby improving reliability of the cache response data, and also avoiding the need of obtaining new data requested by a server every time of the request, and reducing data communication times.
To facilitate understanding of the present embodiment, first, a request response method disclosed in the embodiments of the present disclosure is described in detail, where an execution subject of the request response method provided in the embodiments of the present disclosure is generally a computer device with certain computing capability, and the computer device includes, for example: terminal devices or servers or other processing devices. In some possible implementations, the request response method may be implemented by a processor calling computer readable instructions stored in a memory.
Referring to fig. 1, a flowchart of a request response method provided in the embodiment of the present disclosure is shown, where the method includes steps S101 to S103, where:
s101, responding to a network request of a browser, and searching a cache strategy corresponding to the network request; the caching strategy comprises caching timeliness of caching response data corresponding to the network request.
In this step, when obtaining a network request initiated by a browser, a computer device may first store the network request locally, not request data from a server, and search for a cache policy corresponding to the network request, where the cache policy is used to indicate a cache validity of cache response data corresponding to the network request, the cache response data is data fed back by the server for the network request, and the cache validity is a validity period of the cache response data, and from a time point when the computer device receives the data fed back by the server and stores the data as the cache response data, the cache response data may be considered valid within a duration range of the cache validity, and if the cache validity is exceeded, the cache response data may be considered invalid.
Here, the determination manner of the cache policy may be determined according to the characteristics of the network request corresponding to the cache policy, and the characteristics of the network request may include the type of the network request, identification information of the network request, the update frequency of the response data, the difference before and after the update of the response data, and the like.
For example, for a network request with a high update frequency, the caching policy may be no caching or short-term caching, the caching age is 0 or within a threshold range corresponding to the short-term caching, and for a network request with a low update frequency, the caching age corresponding to the network request may be extended.
Here, if the cache policy corresponding to the network request cannot be found, the data may be directly requested from the server, or an initial cache policy may be generated for the network request, and whether the cache response data is valid is determined according to the initial cache policy.
Here, the caching policy may be generated after response data corresponding to a network request is received, and when the response data is received, the caching stability description information of the network request may be updated, and the caching policy of the network request may be determined according to the updated caching stability description information.
When the cache policy is not found, the cache stability information requested by the network may be initialized, the cache stability description information of the network may be configured according to the initial value, and the cache policy may be generated according to the cache stability description information of the initial network.
For example, the cache stability information may include identification information of a resource indicated by the network request, identification information of data corresponding to the resource, data itself corresponding to the resource, a time length for which the resource has not changed, and the number of times for which the resource is requested.
When a network request caching policy is generated for the first time, the network request caching policy can be directly set to 'cache aging is 0', caching stability information is initialized, or the caching policy is determined according to the initialized caching stability information, and the initialized caching stability information can be used for updating the network request caching policy when the network request is acquired next time.
S102, determining whether the cache response data is valid or not based on the cache aging, the cache time stamp of the cache response data and the current time stamp.
After the cache aging of the network request is found, whether the cache response data is valid or not can be judged according to the cache aging, the cache timestamp of the cache response data and the current timestamp, wherein the cache timestamp is a timestamp corresponding to the time when the cache response data is generated, and the current timestamp can be a timestamp of the time when the network request of the browser is detected.
For example, a time interval between the current timestamp and the caching timestamp may be determined, and then the determined time interval is compared with the caching age, and if the determined time interval is less than or equal to the duration corresponding to the caching age, it may be determined that the caching response data is valid, otherwise, it is invalid.
S103, feeding the cache response data back to the browser under the condition that the cache response data are effective.
In this step, if the cache response data is valid, the cache response data may be directly used as response data corresponding to the network request, and the browser may perform page rendering using the cache response data to display the required information, so that by adopting different targeted cache policies for different network requests, the reliability of the cache response data can be effectively improved, and the number of times of requesting data from the server is reduced.
In the event that the cached response data fails, real-time response data corresponding to the network request (i.e., data fed back by the server for the network request) may be requested from the server and fed back to the browser.
In a possible implementation manner, before the cache policy corresponding to the network request is searched in step S101, the cache response data corresponding to the network request is directly fed back to the browser, so that the browser can immediately perform rendering of the cache response data, then the steps of searching the cache policy corresponding to the network request and S102 are performed, if the cache response data is valid, the process is directly ended, and if the cache response data is invalid, the real-time response data corresponding to the network request is requested from the server, and the real-time response data is fed back to the browser, and the browser re-renders the page by using the real-time response data, so that under the condition that the cache response data is valid, the browser can more quickly acquire the required data and perform page rendering.
Further, after the cache response data is fed back to the browser, or after a preset updating condition is met, the server may be requested for the corresponding real-time response data to verify whether the real-time response data and the cache response data are consistent, and if not, the real-time response data is fed back to the browser to enable the browser to re-render the page.
The preset updating condition may be a preset time node, that the cache response data is not updated after exceeding a preset time period, and the like.
When the real-time response data is obtained and the real-time response data is inconsistent with the cache response data, the cache response data can be updated by using the real-time response data, and the cache timestamp of the cache response data is updated to determine whether the updated cache response data is valid.
After the real-time response data is acquired, the cache stability information can be updated, the cache policy is updated according to the updated cache stability information, when the cache stability information of a network request is updated, whether the historical response data fed back by the server in the previous response to the network request is consistent with the real-time response data can be judged, and if the historical response data and the real-time response data are inconsistent, the cache stability description information can be updated according to the historical response data and the attribute information of the real-time response data, a replacement cache policy of the network request is generated by using the updated cache stability description information, and the cache policy corresponding to the network request is updated by using the replacement cache policy.
The attribute information may include identification information of a method function corresponding to the network request, path information of the network request, a value of the response data, a hash value of the response data, a timestamp when the response data is acquired from the server, serialized request parameters, and the like.
In a possible implementation manner, if the historical response data is consistent with the implementation response data, a consistency comparison result between the historical response data and the real-time response data may be determined based on attribute information of the historical response data and attribute information of the real-time response data, then cache stability description information of the network request may be updated based on the determined consistency comparison result, and finally a replacement cache policy of the network request may be generated according to the updated stability description information. Of course, there may be situations where the newly generated replacement caching policy is the same as the original get caching policy.
Specifically, after the response stabilization duration and the response stabilization frequency are updated, the response stabilization level in the stability description information may be updated, a target response stabilization level may be obtained through a calculation relationship between the response stabilization duration and the response stabilization frequency and the response stabilization level, and the target response stabilization level may be weighted by the response stabilization level before updating, so that the updated response stabilization level may be obtained. After the updated response stability level is obtained, the cache policy corresponding to the response stability level can be determined as a replacement cache policy.
Referring to fig. 3, a flowchart of a step of generating a cache score in an embodiment of the present disclosure is shown, in the step, a resource identifier may be generated by using identification information of a method function corresponding to a network request, path information of the network request, and a serialized request parameter, then, a server is used to generate a result identifier according to a value of response data and a hash value thereof for response data of the network request, the result identifier and the resource identifier are stored as a key value pair, then, a comparison between historical response data and real-time response data is performed according to the stored key value pair, and cache stability information, such as response stability duration (duration in which response data is not changed, open _ time) and response stability times (number of times in which response data is not changed, open _ count) is updated according to a comparison result and the attribute information, and finally, based on the updated cache stability information, a cache score (i.e., the response stability level described above) is generated, and a cache policy may be determined using the cache score.
Further, if the historical response data is inconsistent with the real-time response data, it is indicated that the response data is updated, the response stabilization times, the response stabilization duration and the response stabilization level may be initialized, the initialization may be adjusted to a preset value or 0, and then, the cache policy may be updated according to the updated cache stability description information, so that the cache timeliness of the cache response data is changed, and the reliability of the cache response data is improved.
Referring to fig. 2, a flowchart of another request response method provided by the embodiment of the present disclosure is shown, where the method includes steps S1 to S7, first, step S1 responds to a network request initiated by a browser webpage, then step S2 determines whether a cache policy of the request exists, if so, step S3 is skipped to, and the cached data is responded to the webpage, then step S4 determines whether the data needs to be updated according to the cache policy, if not, the data is directly ended, if so, step S5 is skipped to, a real network request is initiated to the server, data which is obtained and fed back to the browser response server through step S6 is acquired, and finally, the cache policy of the network request is generated or updated through step S7 and ended; if it is determined in step S2 that no caching policy exists, the process may directly go to step S5 and execute the following steps S6 and S7.
The request response method provided by the embodiment of the disclosure includes firstly responding to a network request of a browser and searching a cache strategy corresponding to the network request; the caching strategy comprises caching timeliness of caching response data corresponding to the network request; then, determining whether the cache response data is valid or not based on the cache aging, the cache time stamp of the cache response data and the current time stamp; and finally, feeding back the cache response data to the browser under the condition that the cache response data are effective. According to the method and the device, whether the cache response data are effective or not is judged through the cache strategy deployed for the network request, the cache time stamp of the cache response data and the current time stamp, different cache strategies can be configured according to the characteristics of different network requests, so that the cache response data of different network requests have different cache timeliness, the reliability of the cache response data is improved, new data of the request is not required to be obtained from a server every time, and the data communication frequency is reduced.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
Based on the same inventive concept, a request response device corresponding to the request response method is also provided in the embodiments of the present disclosure, and since the principle of solving the problem of the device in the embodiments of the present disclosure is similar to the request response method described above in the embodiments of the present disclosure, the implementation of the device may refer to the implementation of the method, and repeated details are not described herein.
Referring to fig. 4, a schematic diagram of a request response apparatus provided in an embodiment of the present disclosure is shown, where the apparatus includes:
the searching module 410 is configured to search, in response to a network request of a browser, a cache policy corresponding to the network request; the caching strategy comprises caching timeliness of caching response data corresponding to the network request;
a determining module 420, configured to determine whether the cache response data is valid based on the cache aging, the cache timestamp of the cache response data, and the current timestamp;
a response module 430, configured to feed back the cached response data to the browser if the cached response data is valid.
In an optional implementation, the lookup module 410 is further configured to:
initializing the cache stability description information of the network request under the condition that the cache strategy is not found;
and determining a cache strategy corresponding to the network request based on the cache stability description information of the network request.
In an optional implementation, the response module 430 is further configured to:
and under the condition that the cache response data is invalid, requesting the real-time response data corresponding to the network request from a server, and feeding back the real-time response data to the browser.
In an optional implementation, the response module 430 is further configured to:
after the cache response data are fed back to the browser or after preset updating conditions are met, requesting real-time response data corresponding to the network request from a server;
and if the real-time response data is inconsistent with the cache response data, feeding back the real-time response data to the browser.
In an optional implementation, the response module 430 is further configured to:
and updating the cache response data by using the real-time response data, and updating the cache time stamp of the cache response data.
In an optional implementation, the response module 430 is further configured to:
obtaining attribute information of historical response data fed back by the server when the network request is responded at the previous time;
generating a replacement cache policy of the network request based on the attribute information of the historical response data, the attribute information of the real-time response data and the cache stability description information of the network request;
and updating the cache strategy corresponding to the network request by using the replacement cache strategy.
In an optional implementation, the response module 430, when generating the replacement caching policy of the network request based on the attribute information of the historical response data, the attribute information of the real-time response data, and the caching stability description information of the network request, is configured to:
determining a consistency comparison result of the historical response data and the real-time response data based on the attribute information of the historical response data and the attribute information of the real-time response data;
updating the cache stability description information of the network request based on the consistency comparison result of the determined historical response data and the real-time response data;
and generating a replacement caching strategy of the network request based on the updated stability description information.
In an alternative embodiment, the response module 430, when updating the cache stability description information of the network request based on the determined consistency comparison result between the historical response data and the real-time response data, is configured to:
if the historical response data is consistent with the real-time response data, updating the response stabilization times and the response stabilization duration in the cache stability description information;
and updating the response stability grade based on the updated response stability times and response stability duration and the response stability grade in the stability description information before updating.
In an optional embodiment, the response module 430 updates the cache stability description information of the network request based on the determined consistency comparison result between the historical response data and the real-time response data. For:
and if the historical response data is inconsistent with the real-time response data, initializing the response stabilization times, the response stabilization duration and the response stabilization grade in the cache stability description information.
In an optional implementation, when generating the replacement caching policy of the network request based on the updated stability profile information, the response module 430 is configured to:
and searching a target cache strategy matched with the response stability grade in the stability description information, and taking the searched target cache strategy as the replacement cache strategy.
The description of the processing flow of each module in the device and the interaction flow between the modules may refer to the related description in the above method embodiments, and will not be described in detail here.
Corresponding to the request response method in fig. 1, an embodiment of the present disclosure further provides an electronic device 500, and as shown in fig. 5, a schematic structural diagram of the electronic device 500 provided in the embodiment of the present disclosure includes:
a processor 51, a memory 52, and a bus 53; the memory 52 is used for storing execution instructions and comprises a memory 521 and an external memory 522; the memory 521 is also referred to as an internal memory, and is used for temporarily storing the operation data in the processor 51 and the data exchanged with the external memory 522 such as a hard disk, the processor 51 exchanges data with the external memory 522 through the memory 521, and when the electronic device 500 operates, the processor 51 communicates with the memory 52 through the bus 53, so that the processor 51 executes the following instructions:
responding to a network request of a browser, and searching a cache strategy corresponding to the network request; the caching strategy comprises caching timeliness of caching response data corresponding to the network request;
determining whether the cache response data is valid based on the cache aging, the cache timestamp of the cache response data, and the current timestamp;
and feeding back the cache response data to the browser under the condition that the cache response data are effective.
In an optional embodiment, the processor 41 is further configured to:
initializing the cache stability description information of the network request under the condition that the cache strategy is not found;
and determining a cache strategy corresponding to the network request based on the cache stability description information of the network request.
In an optional embodiment, the processor 41 is further configured to:
and under the condition that the cache response data is invalid, requesting the real-time response data corresponding to the network request from a server, and feeding back the real-time response data to the browser.
In an optional embodiment, the processor 41 is further configured to:
after the cache response data are fed back to the browser or after preset updating conditions are met, requesting real-time response data corresponding to the network request from a server;
and if the real-time response data is inconsistent with the cache response data, feeding back the real-time response data to the browser.
In an optional embodiment, the processor 41 is further configured to:
and updating the cache response data by using the real-time response data, and updating the cache time stamp of the cache response data.
In an optional embodiment, the processor 41 is further configured to:
obtaining attribute information of historical response data fed back by the server when the network request is responded at the previous time;
generating a replacement cache policy of the network request based on the attribute information of the historical response data, the attribute information of the real-time response data and the cache stability description information of the network request;
and updating the cache strategy corresponding to the network request by using the replacement cache strategy.
In an optional embodiment, in the instructions executed by the processor 41, the generating a replacement cache policy for the network request based on the attribute information of the historical response data, the attribute information of the real-time response data, and the cache stability description information of the network request includes:
determining a consistency comparison result of the historical response data and the real-time response data based on the attribute information of the historical response data and the attribute information of the real-time response data;
updating the cache stability description information of the network request based on the consistency comparison result of the determined historical response data and the real-time response data;
and generating a replacement caching strategy of the network request based on the updated stability description information.
In an alternative embodiment, the updating the cache stability description information of the network request based on the determined consistency comparison result between the historical response data and the real-time response data by the processor 41 includes:
if the historical response data is consistent with the real-time response data, updating the response stabilization times and the response stabilization duration in the cache stability description information;
and updating the response stability grade based on the updated response stability times and response stability duration and the response stability grade in the stability description information before updating.
In an alternative embodiment, the updating the cache stability description information of the network request based on the determined consistency comparison result between the historical response data and the real-time response data by the processor 41 includes:
and if the historical response data is inconsistent with the real-time response data, initializing the response stabilization times, the response stabilization duration and the response stabilization grade in the cache stability description information.
In an optional implementation manner, in the instructions executed by the processor 41, the generating a replacement caching policy of the network request based on the updated stability description information includes:
and searching a target cache strategy matched with the response stability grade in the stability description information, and taking the searched target cache strategy as the replacement cache strategy.
Embodiments of the present disclosure also provide a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps of the request response method described in the above method embodiments. Wherein the storage medium may be a volatile or non-volatile computer-readable storage medium.
The embodiments of the present disclosure also provide a computer program product, where the computer program product carries a program code, and instructions included in the program code may be used to execute the steps of the request response method in the foregoing method embodiments, which may be referred to specifically in the foregoing method embodiments, and are not described herein again.
The computer program product may be implemented by hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK), or the like.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, devices, and methods may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions in actual implementation, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed coupling or direct coupling or communication connection between each other may be through some communication interfaces, indirect coupling or communication connection between devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may also be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present disclosure. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used for illustrating the technical solutions of the present disclosure and not for limiting the same, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can still modify or easily conceive of changes in the technical solutions described in the foregoing embodiments or equivalent substitutions of some technical features within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present disclosure, and should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (13)

1. A request response method, comprising:
responding to a network request of a browser, and searching a cache strategy corresponding to the network request; the caching strategy comprises caching timeliness of caching response data corresponding to the network request;
determining whether the cache response data is valid based on the cache aging, the cache timestamp of the cache response data, and the current timestamp;
and feeding back the cache response data to the browser under the condition that the cache response data are effective.
2. The method of claim 1, further comprising:
initializing the cache stability description information of the network request under the condition that the cache strategy is not found;
and determining a cache strategy corresponding to the network request based on the cache stability description information of the network request.
3. The method of claim 1, further comprising:
and under the condition that the cache response data is invalid, requesting the real-time response data corresponding to the network request from a server, and feeding back the real-time response data to the browser.
4. The method of claim 1, further comprising:
after the cache response data are fed back to the browser or after preset updating conditions are met, real-time response data corresponding to the network request are requested from a server;
and if the real-time response data is inconsistent with the cache response data, feeding back the real-time response data to the browser.
5. The method according to claim 3 or 4, characterized in that the method further comprises:
and updating the cache response data by using the real-time response data, and updating the cache time stamp of the cache response data.
6. The method according to claim 3 or 4, characterized in that the method further comprises:
acquiring attribute information of historical response data fed back by the server when the network request is responded at the previous time;
generating a replacement cache strategy of the network request based on the attribute information of the historical response data, the attribute information of the real-time response data and the cache stability description information of the network request;
and updating the cache strategy corresponding to the network request by using the replacement cache strategy.
7. The method of claim 6, wherein the generating the replacement caching policy for the network request based on the attribute information of the historical response data, the attribute information of the real-time response data, and the caching stability description information of the network request comprises:
determining a consistency comparison result of the historical response data and the real-time response data based on the attribute information of the historical response data and the attribute information of the real-time response data;
updating the cache stability description information of the network request based on the determined consistency comparison result of the historical response data and the real-time response data;
and generating a replacement caching strategy of the network request based on the updated stability description information.
8. The method of claim 7, wherein updating the cache stability description information of the network request based on the determined consistency comparison of the historical response data and the real-time response data comprises:
if the historical response data is consistent with the real-time response data, updating the response stabilization times and the response stabilization duration in the cache stability description information;
and updating the response stability grade based on the updated response stability times and response stability duration and the response stability grade in the stability description information before updating.
9. The method of claim 7, wherein updating the cache stability description information of the network request based on the determined consistency comparison of the historical response data and the real-time response data comprises:
and if the historical response data is inconsistent with the real-time response data, initializing the response stabilization times, the response stabilization duration and the response stabilization grade in the cache stability description information.
10. The method of claim 7, wherein generating the network requested replacement caching policy based on the updated stability description information comprises:
and searching a target cache strategy matched with the response stability grade in the stability description information, and taking the searched target cache strategy as the replacement cache strategy.
11. A request response device, comprising:
the searching module is used for responding to a network request of a browser and searching a cache strategy corresponding to the network request; the caching strategy comprises caching timeliness of caching response data corresponding to the network request;
a determining module, configured to determine whether the cache response data is valid based on the cache aging, the cache timestamp of the cache response data, and the current timestamp;
and the response module is used for feeding back the cache response data to the browser under the condition that the cache response data are effective.
12. An electronic device, comprising: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating over the bus when the electronic device is operating, the machine-readable instructions when executed by the processor performing the steps of the request response method of any of claims 1 to 10.
13. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the request response method according to any one of claims 1 to 10.
CN202210044525.XA 2022-01-14 2022-01-14 Request response method and device Pending CN114531489A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210044525.XA CN114531489A (en) 2022-01-14 2022-01-14 Request response method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210044525.XA CN114531489A (en) 2022-01-14 2022-01-14 Request response method and device

Publications (1)

Publication Number Publication Date
CN114531489A true CN114531489A (en) 2022-05-24

Family

ID=81620206

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210044525.XA Pending CN114531489A (en) 2022-01-14 2022-01-14 Request response method and device

Country Status (1)

Country Link
CN (1) CN114531489A (en)

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20100048469A (en) * 2008-10-31 2010-05-11 에스케이텔레콤 주식회사 Method for content caching using cache server and browser cache, and cache server thereof
US20150347614A1 (en) * 2014-06-01 2015-12-03 Apple Inc. Synchronized Web Browsing Histories: Processing Deletions and Limiting Communications to Server
US9378178B1 (en) * 2015-11-30 2016-06-28 International Business Machines Corporation Enhancing HTTP caching by allowing content sharing of data blocks across resources identified by different uniform resource locators
US20170034302A1 (en) * 2015-07-31 2017-02-02 At&T Intellectual Property I, L.P. Facilitation of efficient web site page loading
CN106993014A (en) * 2016-01-20 2017-07-28 中兴通讯股份有限公司 The method of adjustment of cache contents, apparatus and system
CN108920703A (en) * 2018-07-18 2018-11-30 郑州云海信息技术有限公司 A kind of HTTP cache optimization method and device
CN109788305A (en) * 2018-12-10 2019-05-21 北京爱奇艺科技有限公司 A kind of data cached method for refreshing and device
US10320934B1 (en) * 2015-08-25 2019-06-11 Instart Logic, Inc. One-time cache
CN109885593A (en) * 2019-02-21 2019-06-14 北京字节跳动网络技术有限公司 Method and apparatus for handling information
US20190190961A1 (en) * 2017-12-20 2019-06-20 Cisco Technology, Inc. Semi-active probing framework to gather threat intelligence for encrypted traffic and learn about devices
CN110555040A (en) * 2018-03-30 2019-12-10 阿里巴巴集团控股有限公司 Data caching method and device and server
CN110661826A (en) * 2018-06-28 2020-01-07 北京京东尚科信息技术有限公司 Method for processing network request by proxy server side and proxy server
CN111404713A (en) * 2019-01-02 2020-07-10 中国移动通信有限公司研究院 Network resource adjusting method, device and storage medium
CN113515530A (en) * 2021-03-30 2021-10-19 贵州白山云科技股份有限公司 Cache object updating method, device, equipment and storage medium

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20100048469A (en) * 2008-10-31 2010-05-11 에스케이텔레콤 주식회사 Method for content caching using cache server and browser cache, and cache server thereof
US20150347614A1 (en) * 2014-06-01 2015-12-03 Apple Inc. Synchronized Web Browsing Histories: Processing Deletions and Limiting Communications to Server
US20170034302A1 (en) * 2015-07-31 2017-02-02 At&T Intellectual Property I, L.P. Facilitation of efficient web site page loading
US10320934B1 (en) * 2015-08-25 2019-06-11 Instart Logic, Inc. One-time cache
US9378178B1 (en) * 2015-11-30 2016-06-28 International Business Machines Corporation Enhancing HTTP caching by allowing content sharing of data blocks across resources identified by different uniform resource locators
CN106993014A (en) * 2016-01-20 2017-07-28 中兴通讯股份有限公司 The method of adjustment of cache contents, apparatus and system
US20190190961A1 (en) * 2017-12-20 2019-06-20 Cisco Technology, Inc. Semi-active probing framework to gather threat intelligence for encrypted traffic and learn about devices
CN110555040A (en) * 2018-03-30 2019-12-10 阿里巴巴集团控股有限公司 Data caching method and device and server
CN110661826A (en) * 2018-06-28 2020-01-07 北京京东尚科信息技术有限公司 Method for processing network request by proxy server side and proxy server
CN108920703A (en) * 2018-07-18 2018-11-30 郑州云海信息技术有限公司 A kind of HTTP cache optimization method and device
CN109788305A (en) * 2018-12-10 2019-05-21 北京爱奇艺科技有限公司 A kind of data cached method for refreshing and device
CN111404713A (en) * 2019-01-02 2020-07-10 中国移动通信有限公司研究院 Network resource adjusting method, device and storage medium
CN109885593A (en) * 2019-02-21 2019-06-14 北京字节跳动网络技术有限公司 Method and apparatus for handling information
CN113515530A (en) * 2021-03-30 2021-10-19 贵州白山云科技股份有限公司 Cache object updating method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
US10250526B2 (en) Method and apparatus for increasing subresource loading speed
US11449570B2 (en) Data caching method and apparatus
CN106911780B (en) Service ID generation method, device and system
WO2016026384A1 (en) Client page display method, device and system
CN105095226B (en) Web page resources loading method and device
US10489476B2 (en) Methods and devices for preloading webpages
US9195773B2 (en) Structure-based adaptive document caching
CN108023867B (en) Method for filtering mobile terminal webpage advertisement, gateway server and filtering server
CN110928904A (en) Data query method and device and related components
EP2724243A1 (en) Dynamic content caching
WO2012009191A1 (en) Method and apparatus of processing nested fragment caching of a web page
JP2011505615A (en) Statistical application in OLTP environment
CN113886743B (en) Method, device and system for refreshing cache resources
CN108256014B (en) Page display method and device
CN109634753B (en) Data processing method, device, terminal and storage medium for switching browser kernels
CN110795395A (en) File deployment system and file deployment method
CN107918617B (en) Data query method and device
US9317432B2 (en) Methods and systems for consistently replicating data
CN111291083B (en) Webpage source code data processing method and device and computer equipment
CN106547751A (en) Data cached update method and device
CN114531489A (en) Request response method and device
CN110866286B (en) Equipment fingerprint generation method and device
CN112328922A (en) Processing method and device
CN108073660B (en) Method and system for realizing cache data synchronization
CN112989247B (en) Page updating method and device and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Douyin Vision Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: Tiktok vision (Beijing) Co.,Ltd.

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Tiktok vision (Beijing) Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information