CN111131549B - Method for prefetching data by client and storage medium - Google Patents
Method for prefetching data by client and storage medium Download PDFInfo
- Publication number
- CN111131549B CN111131549B CN201911403567.2A CN201911403567A CN111131549B CN 111131549 B CN111131549 B CN 111131549B CN 201911403567 A CN201911403567 A CN 201911403567A CN 111131549 B CN111131549 B CN 111131549B
- Authority
- CN
- China
- Prior art keywords
- prefetching
- client
- domain name
- dns
- name list
- 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.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/45—Network directories; Name-to-address mapping
- H04L61/4505—Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols
- H04L61/4511—Network directories; Name-to-address mapping using standardised directories; using standardised directory access protocols using domain name system [DNS]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/58—Caching of addresses or names
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
- H04L67/568—Storing data temporarily at an intermediate stage, e.g. caching
- H04L67/5681—Pre-fetching or pre-delivering data based on network characteristics
Abstract
The invention provides a method for prefetching data by a client and a storage medium, wherein the method comprises the following steps: presetting a domain name list, a prefetching refresh trigger type and a prefetching period corresponding to a client application; after the client is started, asynchronously executing a prefetching process of the client application: acquiring the last prefetching time; if not, caching data corresponding to the domain name list according to the prefetching refreshing trigger type; if so, according to the prefetching period, refreshing data corresponding to the domain name list in the cache according to the prefetching refreshing trigger type when next prefetching time comes. The invention can reduce the problem of network request failure caused by DNS analysis failure during client network access; particularly, the time consumption and the failure probability during the first access can be reduced, and the problem of access delay caused by DNS analysis in the scene with changed environment where the client is located can be solved; furthermore, the invention has the characteristics of flexible and convenient configuration and high practicability.
Description
Technical Field
The invention relates to the field of interaction between a client and a server, in particular to a method for prefetching data by the client and a storage medium.
Background
Network communication is mostly based on TCP/IP, which is based on IP addresses. Computers can only recognize IP addresses such as "202.96.134.133" when communicating over a network, but cannot recognize domain names. We cannot remember the website with more than 10 IP addresses, so we access the website more than to enter the domain name in the browser address bar to get the required page. This is because a computer called "DNS server" automatically "translates" the domain name we input into the corresponding IP address, and then calls out the web page corresponding to the IP address.
In a simple way, the DNS server automatically translates the domain name into a corresponding IP address. The problem of DNS is easily overlooked. The main problems of DNS are 2, one is that a domestic domain name has a time consumption of tens to a hundred and more milliseconds in domestic network DNS resolution, while the same domain name has a time consumption of two to three times that of domestic domain names in foreign networks. Meanwhile, even in a domestic network, DNS resolution fails in 2G, 3G, and various weak networks.
The DNS resolution efficiency has a great impact on the time consumption of the first network access and the network success rate. Because DNS resolution is important, a DNS pre-reading scheme is provided in existing browsers. The field is set in an x-DNS-prefetch-control header of the browser, and a switch of the field is set to turn on or off a DNS pre-reading function of the browser, so that the resolution speed of the DNS is increased. However, the function is currently implemented with less support in the mobile browser kernel, and how the mobile browser currently H5 or other browsers implement the similar read-ahead function described above.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: a method and a storage medium related to client pre-fetching data are provided, which realize a DNS pre-fetching function in a mobile browser memory to improve DNS resolution efficiency.
In order to solve the technical problems, the invention adopts the technical scheme that:
a method of client prefetching data, comprising:
presetting a domain name list, a prefetching refresh trigger type and a prefetching period corresponding to a client application;
after the client is started, asynchronously executing a prefetching process of the client application:
acquiring the last prefetching time; if not, caching data corresponding to the domain name list according to the prefetching refreshing trigger type; if so, according to the prefetching period, refreshing data corresponding to the domain name list in the cache according to the prefetching refreshing trigger type when next prefetching time comes.
The invention provides another technical scheme as follows:
a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, is able to carry out the steps of a method for prefetching data by a client as described above.
The invention has the beneficial effects that: the method comprises the steps of obtaining a domain name list of a client and refreshing DNS parameter information when the client is started by pre-configuring the DNS domain name list which needs refreshing by the client, and caching data of the DNS domain name list if the DNS domain name list accords with the refreshing DNS parameter information, so that the function similar to the function of pre-reading DNS cache by a Web browser is realized; and further, the occurrence of network access failure of the client is reduced, and particularly, the problems of time consumption in the first access through the domain name and access delay caused by DNS resolution are reduced.
Drawings
Fig. 1 is a schematic flowchart illustrating a method for prefetching data by a client according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a method for prefetching data by a client according to an embodiment of the present invention.
Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
The most key concept of the invention is as follows: the method comprises the steps of obtaining a domain name list and refreshing DNS parameter information when a client is started by pre-configuring a DNS domain name list which needs refreshing by the client application, and caching data of the DNS domain name list if the DNS domain name list accords with the refreshing DNS parameter information.
The technical terms related to the invention are explained as follows:
referring to fig. 1 and fig. 2, the present invention provides a method for prefetching data by a client, including:
presetting a domain name list, a prefetching refresh trigger type and a prefetching period corresponding to a client application;
after the client is started, asynchronously executing a prefetching process of the client application:
acquiring the last prefetching time; if not, caching data corresponding to the domain name list according to the prefetching refreshing trigger type; if so, according to the prefetching period, refreshing data corresponding to the domain name list in the cache according to the prefetching refreshing trigger type when next prefetching time comes.
Further, the caching the data corresponding to the domain name list according to the prefetch refresh trigger type specifically includes:
judging whether the current environment of the client side accords with the prefetching refresh trigger type;
and if so, acquiring and caching data corresponding to the domain name list from the server.
Further, the step of refreshing the data corresponding to the domain name list in the cache according to the prefetch refresh trigger type when the next prefetch time comes includes:
and when the next prefetching time comes, if the current environment of the client side accords with the prefetching refresh trigger type, acquiring data corresponding to the domain name list from a server side, and refreshing the cache.
As can be seen from the above description, the refresh trigger type event predefined by the client and the server, such as a network switching type, a 2G-to-3G change, a mobile network change to Wi-Fi, etc., is preset, and is specifically set according to the service of the application. Therefore, the problem of DNS resolution failure can be reduced by prefetching data in the weak network condition or other parameter change conditions related to DNS resolution.
Furthermore, the method also comprises the steps of presetting a DNS pre-fetching switch of the client application;
the prefetch process further comprises:
if the DNS pre-fetching switch is on, executing the step of acquiring the last pre-fetching time;
if the DNS prefetching switch is off, the prefetching process is ended.
According to the above description, by setting the DNS prefetching switch, a flexible and convenient data prefetching function is provided, more requirements are satisfied, and the practicability is higher.
Further, executing the prefetch process of the asynchronous execution of the client application further includes:
and acquiring a DNS pre-fetching switch, a domain name list, a pre-fetching refresh trigger type and a pre-fetching period corresponding to the client application by asynchronously calling the DNS initialization configuration information interface.
As can be seen from the above description, the DNS initialization configuration information interface is used to obtain the updated DNS parameter information corresponding to the application, so as to provide a convenient execution manner and ensure the correspondence between the obtained parameter information and the application.
Further, the method further comprises:
and configuring a background management interface for maintaining the domain name list.
As can be seen from the above description, through configuration of the background management interface, a convenient way for managing and maintaining the domain name list corresponding to each application is provided for the user, and flexibility of domain name list configuration is improved.
The invention provides another technical scheme as follows:
a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, is able to carry out the steps of a method for prefetching data by a client as described above.
The steps include:
presetting a domain name list, a prefetching refresh trigger type and a prefetching period corresponding to a client application;
after the client is started, asynchronously executing a prefetching process of the client application:
acquiring the last prefetching time; if not, caching data corresponding to the domain name list according to the prefetching refreshing trigger type; if so, according to the prefetching period, refreshing data corresponding to the domain name list in the cache according to the prefetching refreshing trigger type when next prefetching time comes.
Further, the caching the data corresponding to the domain name list according to the prefetch refresh trigger type specifically includes:
judging whether the current environment of the client side accords with the prefetching refresh trigger type;
and if so, acquiring and caching data corresponding to the domain name list from the server.
Further, the step of refreshing the data corresponding to the domain name list in the cache according to the prefetch refresh trigger type when the next prefetch time comes includes:
and when the next prefetching time comes, if the current environment of the client side accords with the prefetching refresh trigger type, acquiring data corresponding to the domain name list from a server side, and refreshing the cache.
Furthermore, the method also comprises the steps of presetting a DNS pre-fetching switch of the client application;
the prefetch process further comprises:
if the DNS pre-fetching switch is on, executing the step of acquiring the last pre-fetching time;
if the DNS prefetching switch is off, the prefetching process is ended.
Further, executing the prefetch process of the asynchronous execution of the client application further includes:
and acquiring a DNS pre-fetching switch, a domain name list, a pre-fetching refresh trigger type and a pre-fetching period corresponding to the client application by asynchronously calling the DNS initialization configuration information interface.
Further, the method further comprises:
and configuring a background management interface for maintaining the domain name list.
As can be understood from the above description, those skilled in the art can understand that all or part of the processes in the above technical solutions can be implemented by instructing related hardware through a computer program, where the program can be stored in a computer-readable storage medium, and when executed, the program can include the processes of the above methods. And after the process is executed, the beneficial effects corresponding to the methods can be obtained.
The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
Example one
Referring to fig. 2, the present embodiment provides a method for prefetching data by a client, which can dynamically refresh a DNS cache, and implement a function similar to that of a Web browser for prefetching a DNS cache, thereby reducing a network request failure and a service failure caused by a DNS resolution failure when a client accesses a network.
The method comprises the following steps:
s1: and presetting a domain name list, a DNS pre-fetching switch, a pre-fetching refreshing trigger type and a pre-fetching period corresponding to the application of the client at the server. Because the domain names used by the applications of the same type are basically the same, the corresponding domain name list, the DNS pre-fetching switch, the pre-fetching refresh trigger type and the pre-fetching period can be preset corresponding to the application type, so that the preset process is simplified.
Specifically, a domain name list composed of domain names that may be used by the client application needs to be obtained in advance. For example, a client APP application, which has 100 interfaces called, may call 10 different domain name addresses, and the 10 domain name addresses host _1 to host _10 form a domain name list, as can be seen from statistical analysis of the 100 interfaces.
In an optimization example, a background management interface is available to perform domain name list maintenance functions for different APPs (or APP types).
Meanwhile, a DNS prefetch switch, a prefetch refresh trigger type, a prefetch cycle, and a prefetch refresh trigger type of the client application need to be preset. The DNS prefetching switch is used for starting and stopping the prefetching function of the client application. The prefetch refresh trigger type refers to a refresh trigger type event which is predefined by the client and the server, namely a condition for triggering prefetching. Such as predefined network handover types: 2G to 3G, mobile network to Wi-Fi, etc.; for example, the type of the location city or the change of the area where the user is located may be specifically set according to the respective services applied. The prefetch period refers to the time between two previous and next execution of the prefetch data flow.
S2: the server provides an interface of DNS initialization configuration information, called as DNS initialization configuration information interface, and the interface is asynchronously called after the client is started each time, enters a prefetching process, is not associated with other main services, and does not influence the use of other services of the client.
S3: the DNS initialization configuration information interface returns a list of domain names used under the application (or application type) and other related information preset corresponding to the application (or application type) according to the application (or application type) requested by the client.
Specifically, the transmission request parameter is an application (or application type), and a domain name list, a DNS prefetch switch, a prefetch refresh trigger type, and a prefetch cycle corresponding to the application (or application type) are returned.
S4: judging the state of a DNS pre-fetching switch corresponding to the current client application returned by the DNS initialization configuration information interface:
if the DNS prefetching switch is off, the prefetching process is ended, the old logic is kept still, and processing is carried out according to the old service logic.
If the DNS prefetching switch is on, the local cache is inquired by the application to acquire the last prefetching time;
if the last time of DNS caching cannot be obtained, the DNS caching operation is performed for the first time; and caching the data corresponding to the domain name list according to the prefetching refresh trigger type. The method specifically comprises the following steps: judging whether the current setting of the client side accords with the prefetching refresh trigger type; for example, whether the client changes from original 2G to 3G, whether the mobile network changes to Wi-Fi, whether the location city changes from Fuzhou to Xiamen, and the like. And if so, acquiring the data corresponding to the domain name list from the server and caching the data. Namely, the DNS domain name request is directly refreshed, and the cache function of the operating system is directly triggered (the program http is directly used for accessing the domain name).
If the time of the last DNS cache can be acquired, comparing the time with the current time, if the time is less than the pre-fetching period, indicating that the DNS refreshing operation is not needed, and if the time is more than or equal to the pre-fetching period, indicating that the DNS refreshing operation is needed, and updating the operating system cache. Specifically, the data corresponding to the domain name list in the cache is refreshed according to the prefetch refresh trigger type as described above.
All business behaviors triggering DNS refreshing operation need to be compared with a prefetching refreshing triggering type returned by a DNS initialization configuration information interface, and domain name prefetching operation can be performed only when a triggering condition is met and a prefetching period is met at the same time.
By the configurable DNS prefetching function, the DNS prefetching function of the APP client can be realized, even if the mobile terminal does not support a browser use scene of an x-DNS-prefetch-control request header, the DNS cache can be dynamically refreshed, and the first access speed is improved.
The embodiment provides a function of refreshing a domain name at regular time, that is, a function of directly requesting a domain name to enable a browser or an application to actively execute domain name resolution when certain conditions are met. The scope includes all links of the document, whether pictures, CSS, or JavaScript, etc. URLs other users can click on. Because the pre-reading is performed in the background, the DNS is likely to have resolved before the link correspondence occurs. This can reduce the delay when the user clicks on a link, in particular the delay time for the first access of an application. The prior art client accesses the server for the first time as well as the old DNS, and the domain name resolution of the DNS is not performed in advance, so the first access request is definitely slow, and the problem can be solved by the present embodiment.
The purpose of this embodiment is to avoid that the time consumed by the client for performing DNS resolution through the domain name for the first time is long because the client performs DNS resolution through the domain name at regular time and caches the relevant information of the domain name locally under the conditions of network switching, region change, and the like. Thus, subsequent other first access requests through the domain name are much faster. The main purpose of the scheme is to quickly respond when an application or a client browser is opened for the first time under different network conditions, and the problem of access delay caused by DNS resolution when the application or the client browser is accessed through a domain name for the first time is obviously reduced.
Example two
This embodiment corresponds to the first embodiment, and provides a computer-readable storage medium, on which a computer program is stored, where the computer program is capable of implementing the steps included in the method for prefetching data by a client according to the first embodiment. The detailed steps are not repeated here, and refer to the description of the first embodiment for details.
In summary, the method and the storage medium for prefetching data by a client provided by the present invention can reduce the occurrence of network request failure caused by DNS resolution failure during network access of the client; particularly, the time consumption and the failure probability during the first access can be reduced, and the problem of access delay caused by DNS analysis in the scene with changed environment where the client is located can be solved; furthermore, the invention has the characteristics of flexible and convenient configuration and high practicability.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.
Claims (7)
1. A method for prefetching data by a client, comprising:
presetting a domain name list, a pre-fetching refresh trigger type and a pre-fetching period corresponding to a client application, wherein the preset refresh trigger type is a trigger type defined according to an application service, and comprises a network switching type;
after the client is started, asynchronously executing a prefetching process of the client application:
acquiring the last prefetching time; if not, caching data corresponding to the domain name list according to the prefetching refreshing trigger type; if so, according to the prefetching period, refreshing data corresponding to the domain name list in the cache according to the prefetching refreshing trigger type when next prefetching time comes.
2. The method for prefetching data by a client according to claim 1, wherein the caching of the data corresponding to the domain name list according to the prefetch refresh trigger type specifically includes:
judging whether the current environment of the client side accords with the prefetching refresh trigger type;
and if so, acquiring and caching data corresponding to the domain name list from the server.
3. The method for prefetching data by a client according to claim 1, wherein the step of refreshing the data corresponding to the domain name list in the cache according to the prefetch refresh trigger type when the next prefetch time comes includes:
and when the next prefetching time comes, if the current environment of the client side accords with the prefetching refresh trigger type, acquiring data corresponding to the domain name list from a server side, and refreshing the cache.
4. The method for prefetching data by a client as in claim 1, further comprising presetting a DNS prefetch switch for a client application;
the prefetch process further comprises:
if the DNS pre-fetching switch is on, executing the step of acquiring the last pre-fetching time;
if the DNS prefetching switch is off, the prefetching process is ended.
5. The method as claimed in claim 4, wherein the step of performing the asynchronous prefetch process of the client application further comprises:
and acquiring a DNS pre-fetching switch, a domain name list, a pre-fetching refresh trigger type and a pre-fetching period corresponding to the client application by asynchronously calling the DNS initialization configuration information interface.
6. The method for prefetching data by a client as in claim 1, wherein the method further comprises:
and configuring a background management interface for maintaining the domain name list.
7. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, is adapted to carry out the steps of a method for prefetching data by a client as claimed in any of the preceding claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911403567.2A CN111131549B (en) | 2019-12-31 | 2019-12-31 | Method for prefetching data by client and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911403567.2A CN111131549B (en) | 2019-12-31 | 2019-12-31 | Method for prefetching data by client and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111131549A CN111131549A (en) | 2020-05-08 |
CN111131549B true CN111131549B (en) | 2022-04-01 |
Family
ID=70505946
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911403567.2A Active CN111131549B (en) | 2019-12-31 | 2019-12-31 | Method for prefetching data by client and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111131549B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104184841A (en) * | 2013-05-23 | 2014-12-03 | 携程计算机技术(上海)有限公司 | Website DNS (domain name resolution) accelerating method and client |
CN106161669A (en) * | 2015-04-28 | 2016-11-23 | 阿里巴巴集团控股有限公司 | A kind of quick domain name analytic method and system and terminal thereof and server |
CN110519401A (en) * | 2019-07-05 | 2019-11-29 | 中国平安财产保险股份有限公司 | Improve method, apparatus, equipment and the storage medium of network Access Success Rate |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8677018B2 (en) * | 2008-08-25 | 2014-03-18 | Google Inc. | Parallel, side-effect based DNS pre-caching |
US9197486B2 (en) * | 2008-08-29 | 2015-11-24 | Google Inc. | Adaptive accelerated application startup |
-
2019
- 2019-12-31 CN CN201911403567.2A patent/CN111131549B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104184841A (en) * | 2013-05-23 | 2014-12-03 | 携程计算机技术(上海)有限公司 | Website DNS (domain name resolution) accelerating method and client |
CN106161669A (en) * | 2015-04-28 | 2016-11-23 | 阿里巴巴集团控股有限公司 | A kind of quick domain name analytic method and system and terminal thereof and server |
CN110519401A (en) * | 2019-07-05 | 2019-11-29 | 中国平安财产保险股份有限公司 | Improve method, apparatus, equipment and the storage medium of network Access Success Rate |
Also Published As
Publication number | Publication date |
---|---|
CN111131549A (en) | 2020-05-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10887418B1 (en) | Parallel, side-effect based DNS pre-caching | |
US9654542B2 (en) | Adaptive accelerated application startup | |
CN102438045B (en) | Method and system for pre-fetching web page, and method for accessing web page | |
CN112073405B (en) | Webpage data loading method and device, computer equipment and storage medium | |
US8527862B2 (en) | Methods for making ajax web applications bookmarkable and crawlable and devices thereof | |
US9588854B2 (en) | Systems and methods for a secondary website with mirrored content for automatic failover | |
US10291738B1 (en) | Speculative prefetch of resources across page loads | |
CN106294365A (en) | The page data processing method of a kind of single page web application and equipment | |
US20130268831A1 (en) | Method, device, and system for acquiring start page | |
US20170300459A1 (en) | Card-type desktop implementation method and apparatus | |
CN111367596B (en) | Method and device for realizing business data processing and client | |
CN110730196A (en) | Network resource access method, computer equipment and storage medium | |
CN109634753B (en) | Data processing method, device, terminal and storage medium for switching browser kernels | |
CN115668894A (en) | Service worker configured to service a plurality of single-page applications | |
CN111131549B (en) | Method for prefetching data by client and storage medium | |
CN109190071A (en) | Mobile terminal caching method and device | |
CN111814085A (en) | Novel WEB online agent method based on JavaScript hook | |
CN116302175A (en) | Concurrent network request processing method, device, equipment and storage medium | |
CN113157738B (en) | In-heap data cache synchronization method and device, computer equipment and storage medium | |
US20220092144A1 (en) | Intelligent dynamic preloading | |
CN111090675B (en) | Multi-entry data caching method and storage medium | |
WO2016069951A1 (en) | Method and system of content caching and transmission | |
CN113806655A (en) | Data processing method and device, electronic equipment and storage medium | |
CN115270027A (en) | Webpage data acquisition method and device, electronic equipment and storage medium | |
CN114461950A (en) | Global caching method and device, electronic equipment and 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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |