CN110300163B - Method, device, equipment and storage medium for acquiring network data - Google Patents

Method, device, equipment and storage medium for acquiring network data Download PDF

Info

Publication number
CN110300163B
CN110300163B CN201910554535.6A CN201910554535A CN110300163B CN 110300163 B CN110300163 B CN 110300163B CN 201910554535 A CN201910554535 A CN 201910554535A CN 110300163 B CN110300163 B CN 110300163B
Authority
CN
China
Prior art keywords
network
network request
signal
network data
request
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
Application number
CN201910554535.6A
Other languages
Chinese (zh)
Other versions
CN110300163A (en
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 CN201910554535.6A priority Critical patent/CN110300163B/en
Publication of CN110300163A publication Critical patent/CN110300163A/en
Application granted granted Critical
Publication of CN110300163B publication Critical patent/CN110300163B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/566Grouping or aggregating service requests, e.g. for unified processing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Abstract

The embodiment of the disclosure discloses a method, a device, equipment and a storage medium for acquiring network data. The method comprises the following steps: when a trigger event for sending a network request is detected on a current display page, determining whether the trigger event meets a preset cache condition; if so, acquiring network data corresponding to the network request from the cached data; if not, sending a network request to the server to acquire network data corresponding to the network request. According to the technical scheme of the embodiment of the disclosure, when the same network data is required to be acquired again when the same display page is displayed or the display page is switched to other display pages, the network data can be directly acquired from the cached data without repeatedly sending the network request to the server, so that the times of sending the network request by the client are reduced, and the network flow is saved.

Description

Method, device, equipment and storage medium for acquiring network data
Technical Field
The embodiment of the disclosure relates to the technical field of application program development, and in particular, to a method, an apparatus, a device and a storage medium for acquiring network data.
Background
Currently, when a user performs an operation of requesting to acquire certain network data based on a display page of an Application (APP) on a client, the client sends a network request to a server to download the requested network data, such as author information of an article, sent by the server.
When the same page is displayed or switched to other pages, if the user needs to acquire the same network data, the client needs to send the same network request to the server again to download the network data requested to be acquired again. In the above scheme, when a user needs to obtain the same network data at different times, the client needs to send the same network request to the server for multiple times, and a large number of network request times is a large waste of network traffic.
Disclosure of Invention
The embodiment of the disclosure provides a method, a device, equipment and a storage medium for acquiring network data, which can reduce the times of sending network requests by a client and save network traffic.
In a first aspect, an embodiment of the present disclosure provides a method for acquiring network data, which may include:
when a trigger event for sending a network request is detected on a current display page, determining whether the trigger event meets a preset cache condition;
if so, acquiring network data corresponding to the network request from the cached data;
if not, sending a network request to the server to acquire network data corresponding to the network request.
In the foregoing scheme, optionally, after sending the network request to the server to obtain the network data corresponding to the network request, the method may further include:
and converting a cold signal corresponding to the network request into a hot signal, and buffering the hot signal, wherein the buffered hot signal comprises network data corresponding to the network request.
In the foregoing scheme, optionally, if yes, obtaining network data corresponding to the network request from the cached data may include:
if the network data corresponding to the network request is included in the buffered hot signals, the network data corresponding to the network request is obtained from the buffered hot signals.
In the foregoing scheme, optionally, if not, sending a network request to the server to obtain network data corresponding to the network request may include:
and if the triggering event is the first triggering, or the triggering event is the second triggering and the network data corresponding to the network request is not included in the cached heat signal, sending the network request to the server to acquire the network data corresponding to the network request.
In the foregoing solution, optionally, the method for acquiring network data may further include:
and when the triggering operation of entering the current display page is detected, packaging each network request related in the current display page into cold signals respectively.
In the foregoing scheme, optionally, the buffering the thermal signal may include: the thermal signal is buffered in memory.
In the foregoing scheme, optionally, buffering the thermal signal in a memory may include: buffering the thermal signal in a queue, and buffering the queue in a memory; the buffer amount of the queue is less than or equal to a preset value.
In the foregoing scheme, optionally, before buffering the thermal signal in the queue, the method for acquiring network data may further include: and if the current buffer amount of the queue is equal to the preset value, deleting the heat signal at the head position of the queue in the queue.
In a second aspect, an embodiment of the present disclosure further provides an apparatus for acquiring network data, which may include:
the cache condition judging module is used for determining whether the trigger event meets the preset cache condition or not when the trigger event for sending the network request is detected on the current display page;
the network data acquisition module is used for acquiring network data corresponding to the network request from the cached data if the network data acquisition module is used for acquiring the network data corresponding to the network request from the cached data;
and the network data request module is used for sending a network request to the server to acquire network data corresponding to the network request if the network data request module does not send the network request to the server.
In the foregoing solution, optionally, the apparatus for acquiring network data may further include:
and the hot signal caching module is used for converting the cold signal corresponding to the network request into a hot signal and caching the hot signal, wherein the cached hot signal comprises network data corresponding to the network request.
In the foregoing scheme, optionally, the network data obtaining module may be specifically configured to:
if the network data corresponding to the network request is included in the buffered hot signals, the network data corresponding to the network request is obtained from the buffered hot signals.
In the foregoing scheme, optionally, the network data request module may be specifically configured to:
and if the triggering event is the first triggering, or the triggering event is the second triggering and the network data corresponding to the network request is not included in the cached heat signal, sending the network request to the server to acquire the network data corresponding to the network request.
In the foregoing solution, optionally, the apparatus for acquiring network data may further include:
and the cold signal packaging module is used for respectively packaging each network request related in the current display page into a cold signal when the triggering operation of entering the current display page is detected.
In the foregoing scheme, optionally, the thermal signal buffering module may include:
and the heat signal caching unit is used for caching the heat signal in the memory.
In the foregoing scheme, optionally, the thermal signal buffering unit may include:
the hot signal buffer subunit is used for buffering the hot signals in the queue and buffering the queue in the memory; wherein the buffer amount of the queue is less than or equal to a preset value.
In the foregoing solution, optionally, the apparatus for acquiring network data may further include:
and the thermal signal deleting module is used for deleting the thermal signal at the head position in the queue if the current buffer amount of the queue is equal to a preset numerical value.
In a third aspect, an embodiment of the present disclosure further provides a terminal device, which may include:
one or more processors;
a memory for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the network data acquisition method provided by any embodiment of the present disclosure.
In a fourth aspect, the embodiments of the present disclosure further provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method for acquiring network data provided in any embodiment of the present disclosure.
According to the technical scheme of the embodiment of the disclosure, when a trigger event for sending a network request is detected on a current display page, whether the trigger event meets a preset cache condition is determined; if the network request is satisfied, namely the cached data on the client comprises the network data corresponding to the network request, the network data corresponding to the network request can be directly obtained from the cached data without sending the network request to the server again; if the network request is not satisfied, that is, the network data corresponding to the network request is not included in the cached data on the client, the network request needs to be sent to the server to obtain the network data corresponding to the network request. According to the technical scheme, when the same network data is required to be acquired again when the same display page is displayed or the display page is switched to other display pages, the network data can be directly acquired from the cached data without repeatedly sending network requests to the server, so that the times of sending the network requests by the client are reduced, and the network flow is saved.
Drawings
Fig. 1 is a flowchart of a method for acquiring network data according to a first embodiment of the present disclosure;
fig. 2 is a flowchart of a network data acquisition method in a second embodiment of the disclosure;
fig. 3 is a block diagram of a network data acquisition apparatus in a third embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a terminal device in a fourth embodiment of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the disclosure and are not limiting of the disclosure. It should be further noted that, for the convenience of description, only some of the structures relevant to the present disclosure are shown in the drawings, not all of them.
In the following embodiments, optional features and examples are provided in each embodiment, and various features described in the embodiments may be combined to form a plurality of alternatives, and each numbered embodiment should not be regarded as only one technical solution.
Example one
Fig. 1 is a flowchart of a method for acquiring network data according to a first embodiment of the disclosure. The embodiment is applicable to the situation of acquiring network data, and is particularly applicable to the situation of acquiring the same network data for multiple times. The method can be executed by the network data acquisition device provided by the embodiment of the disclosure, the device can be realized by software and/or hardware, and the device can be integrated on various user terminal devices or servers. Referring to fig. 1, the method of the embodiment of the present disclosure specifically includes the following steps:
s110, when the current display page detects a trigger event for sending the network request, determining whether the trigger event meets a preset caching condition.
For example, the preset caching condition may relate to whether the trigger event is triggered for the first time or triggered again, may relate to whether network data corresponding to the network request is cached, and may also relate to the number of triggers of the trigger event and the caching condition of the network data.
Specifically, there are many ways to determine whether to cache the network data corresponding to the network request, for example, if there is network data corresponding to a certain network request in the client, the network data and the network request may appear in pairs, and particularly, since each network request may be associated with a unique hash value, the network data and the hash value associated with the network request may appear in pairs, where the hash value may include a hash value of an address corresponding to the server to which the network request is sent. Further, the client may find whether the hash value associated with the network request corresponding to the trigger event is cached, and if so, it indicates that the network data corresponding to the network request is cached on the client.
Specifically, there are many ways to determine whether a trigger event is triggered first or triggered again, for example, if each trigger event is associated with a preset flag bit, the flag bit can be used to determine whether the trigger event is triggered first or triggered again. For example, assuming that the flag bit of a trigger event that is not triggered is NO, if the trigger event belongs to the first trigger, the flag bit at the time of triggering is NO, and after the trigger event occurs, the APP in the client may convert the flag bit from NO to YES; if the trigger event is triggered again, the flag bit at the trigger time point is YES, and after the trigger event occurs, the APP does not perform any operation on the flag bit. It should be noted that the flag bit of each trigger event is cached in the memory, and only when the APP is to be released from the memory, the flag bit of the APP will be changed from YES to NO, which means that the trigger event is never triggered. On the basis, for example, when a current display page detects a trigger event for sending a network request, if the flag bit of the trigger event is NO, the trigger event is indicated as a first trigger; if the flag bit of the trigger event is YES, the trigger event is a re-trigger, for example, the trigger event may be a second trigger, a third trigger, a fourth trigger, etc.
And S120, if so, acquiring network data corresponding to the network request from the cached data.
If the trigger event meets the preset caching condition, that is, the cached data on the client includes the network data corresponding to the network request, the network data corresponding to the network request can be directly acquired from the cached data. For example, if the triggering event is a re-trigger, that is, the network request is sent again, the network data corresponding to the network request may be cached in some location of the client, such as a memory, a hard disk, or the like. Therefore, taking the case that the network data and the hash value associated with the network request occur in pairs as an example, for example, if the hash value corresponding to the network request is found in the cached data, it indicates that the network data corresponding to the network request is cached on the client. Particularly, since the network data is cached on the client, when the same display page is subsequently displayed or other display pages are switched to, if the same network data needs to be acquired again, the corresponding network data can be directly acquired and displayed according to the hash value, that is, the network request does not need to be sent to the server again, so that the number of times that the client sends the network request is reduced, and the network traffic is saved.
And S130, if not, sending a network request to the server to acquire network data corresponding to the network request.
If the trigger event does not meet the preset caching condition, that is, the cached data on the client does not include the network data corresponding to the network request, the network request needs to be sent to the server to obtain the network data corresponding to the network request. For example, if the triggering event is a first trigger, that is, the network request is sent for the first time, it means that it is impossible to cache the network data corresponding to the network request at any location of the client. Therefore, the APP in the client needs to send the network request to the server to download the network data requested to be acquired, which is sent by the server. For another example, if the triggering event is a re-trigger, but the network data corresponding to the network request is not found in the cached data, it may be said that for some reason, the client deletes the cached network data corresponding to the network request. At this time, the client needs to send a network request to the server again to download the network data requested to be acquired again.
According to the technical scheme of the embodiment of the disclosure, when a trigger event for sending a network request is detected on a current display page, whether the trigger event meets a preset cache condition is determined; if the network request is satisfied, namely the cached data on the client comprises the network data corresponding to the network request, the network data corresponding to the network request can be directly obtained from the cached data without sending the network request to the server again; if the network request is not satisfied, that is, the network data corresponding to the network request is not included in the cached data on the client, the network request needs to be sent to the server to obtain the network data corresponding to the network request. According to the technical scheme, when the same network data is required to be acquired again when the same display page is displayed or the display page is switched to other display pages, the network data can be directly acquired from the cached data without repeatedly sending network requests to the server, so that the times of sending the network requests by the client are reduced, and the network flow is saved.
Example two
Fig. 2 is a flowchart of a network data acquisition method provided in the second embodiment of the present disclosure. The present embodiment is optimized based on the first embodiment. In this embodiment, after sending a network request to a server to obtain network data corresponding to the network request, the method for obtaining network data may further include: and converting a cold signal corresponding to the network request into a hot signal, and buffering the hot signal, wherein the buffered hot signal comprises network data corresponding to the network request. Correspondingly, as shown in fig. 2, the method of this embodiment may specifically include the following steps:
s210, when the current display page detects a trigger event for sending the network request, determining whether the trigger event meets a preset caching condition.
S220, if yes, network data corresponding to the network request are obtained from the cached data
And S230, if not, sending a network request to the server to acquire network data corresponding to the network request, converting a cold signal corresponding to the network request into a hot signal, and caching the hot signal, wherein the cached hot signal comprises the network data corresponding to the network request.
After the network data is acquired, the APP may convert a cold signal corresponding to the network request into a hot signal, and cache the hot signal in the client, where the cached hot signal may include the network data corresponding to the network request, and at the same time, may also include a hash value corresponding to the network request.
The cold signal involved in the above steps can be considered as a re-encapsulation of the network request, which is a type of data with a fixed format. The cold signal can only be used for requesting network data, and cannot cache the network data acquired from the server. Correspondingly, the hot signal may be considered as a result of converting the cold signal, and the hot signal may include network data corresponding to the network request corresponding to the cold signal, that is, the hot signal may be network data that can be obtained from the server side by caching; meanwhile, the hot signal may further include a hash value corresponding to the network request corresponding to the cold signal.
However, since the network request can only be encapsulated as a cold signal and cannot be directly encapsulated as a hot signal, that is, the APP in the client cannot send the network request in the form of a hot signal, the APP needs to encapsulate the network request as a cold signal and convert the cold signal into a hot signal after acquiring the network data. Actually, in the process of sending the network request to the server, the client may directly send the network request, or may send a cold signal corresponding to the network request. Because, no matter whether the client sends the network request or the cold signal, the server receives the network request, that is, the server cannot know whether the client performs the network request by any technical means, and what the server receives is only the substance corresponding to the network request.
Accordingly, for example, if the cold signal corresponding to the network request is converted into the hot signal and the hot signal is buffered, and the buffered hot signal includes network data corresponding to the network request, if so, obtaining the network data corresponding to the network request from the buffered data may include: if the network data corresponding to the network request is included in the cached thermal signal, acquiring the network data corresponding to the network request from the cached thermal signal; if not, sending a network request to the server to obtain network data corresponding to the network request, which may include: and if the triggering event is the first triggering, or the triggering event is the second triggering and the network data corresponding to the network request is not included in the cached heat signal, sending the network request to the server to acquire the network data corresponding to the network request.
According to the technical scheme of the embodiment of the disclosure, when the cold signal corresponding to the network request is converted into the hot signal and the hot signal is cached, the network data can be directly obtained from the cached hot signal when the network data corresponding to the network request needs to be obtained again, and the network request does not need to be repeatedly sent to the server, so that the frequency of sending the network request by the client is reduced, and the network flow is saved.
On the basis of the above technical solution, optionally, when detecting the trigger operation of entering the current display page, the APP may encapsulate each network request related in the current display page as a cold signal, so that each network request is associated with a preset cold signal, and the cold signals may be different from each other. But at this time, the APP does not perform the network request or the sending of the cold signal. The method has the advantages that when the APP monitors any network request on the current display page, the cold signal corresponding to the network request can be immediately acquired, and the operation is more convenient. Particularly, since only the network request of the current display page is encapsulated as the cold signal, the network requests of the display pages involved in the APP are not all encapsulated as the cold signal, which occupies less resources and further requires less performance of the system.
Based on the above technical solution, optionally, the property of the thermal signal enables the thermal signal to be buffered in the memory of the client, for example, the thermal signal is buffered in the memory in the form of a queue, an array, a stack, or the like. This arrangement has the advantage of faster reading of the network data in the buffered thermal signal, compared to caching the network data directly in the hard disk of the client. Moreover, when the APP in the client is released from the memory, all information related to the APP will be automatically destroyed from the memory, such as a flag bit of a trigger event, network data in a thermal signal, and the like, which can effectively avoid the problem of data accumulation in the client and does not require a user to manually destroy data; correspondingly, if the current display page is switched to other display pages, as long as the APP is not released from the memory, even if the current display page is switched to other display pages, the network data in the current display page still exist, that is, the network data can still be directly acquired. As can be seen from the above, by caching the thermal signal in the memory, the network data corresponding to the thermal signal can be quickly read when the current display page or other display pages are switched to; moreover, the network data can be automatically destroyed along with the release of the APP, and the resource occupation is less.
In particular, the hot signal is active compared to the cold signal, it can actively send the network data into the memory, i.e. the hot signal can actively buffer the network data in the memory, and the buffering operation is performed in the sub-thread of the client; correspondingly, the interface display of the APP and the response processing of the user to various operations of the APP are carried out in the main thread of the client, namely the cache operation of the hot signal cannot influence any operation directly related to the user, such as the problem of blocking, and the smooth application of the APP can be ensured while the network flow is saved. Further, when the cached thermal signal includes a hash value corresponding to the network request, the main thread may directly request the sub-thread for network data corresponding to the hash value.
On the basis of the above technical solution, optionally, the thermal signal may be buffered in a queue, and the queue is buffered in a memory; wherein the buffer amount of the queue is less than or equal to a preset value. Specifically, optionally, if the current buffer amount of the queue is equal to the preset value, the heat signal at the head position of the queue in the queue may be deleted, and then the heat signal is buffered in the queue, and the queue is buffered in the memory. The buffer amount of the queue, i.e. the number of thermal signals that can be buffered in the queue, may be limited to avoid the problem of data accumulation. Furthermore, the first-in first-out nature of the queue allows the hot signal queued at the head of the queue to be directly deleted if the current amount of buffering of the queue equals a preset value, so as to buffer the newly acquired hot signal. The buffering time of the thermal signal queued at the head of the queue is earliest compared to other thermal signals. It should be noted that, for those network requests corresponding to the deleted hot signals, the client may re-encapsulate the network requests into cold signals, so as to perform the relevant operation when sending the network requests again.
EXAMPLE III
Fig. 3 is a block diagram of a network data acquisition apparatus according to a third embodiment of the present disclosure, where the apparatus is configured to execute a network data acquisition method according to any of the embodiments. The device and the method for acquiring network data of the embodiments belong to the same inventive concept, and details that are not described in detail in the embodiments of the device for acquiring network data may refer to the embodiments of the method for acquiring network data. Referring to fig. 3, the apparatus may specifically include: a cache condition judging module 310, a network data obtaining module 320 and a network data requesting module 330.
The caching condition determining module 310 is configured to determine whether a trigger event meets a preset caching condition when the trigger event for sending the network request is detected on the current display page;
a network data obtaining module 320, configured to obtain, if yes, network data corresponding to the network request from the cached data;
the network data request module 330 is configured to send a network request to the server to obtain network data corresponding to the network request if the network data request is not received.
In the foregoing solution, optionally, the apparatus for acquiring network data may further include:
and the hot signal caching module is used for converting the cold signal corresponding to the network request into a hot signal and caching the hot signal, wherein the cached hot signal comprises network data corresponding to the network request.
In the foregoing scheme, optionally, the network data obtaining module 320 may be specifically configured to:
if the network data corresponding to the network request is included in the buffered hot signals, the network data corresponding to the network request is obtained from the buffered hot signals.
In the foregoing scheme, optionally, the network data request module 330 may be specifically configured to:
and if the triggering event is the first triggering, or the triggering event is the second triggering and the network data corresponding to the network request is not included in the cached heat signal, sending the network request to the server to acquire the network data corresponding to the network request.
In the foregoing solution, optionally, the apparatus for acquiring network data may further include:
and the cold signal packaging module is used for respectively packaging each network request related in the current display page into a cold signal when the triggering operation of entering the current display page is detected.
In the foregoing scheme, optionally, the thermal signal buffering module may include:
and the heat signal caching unit is used for caching the heat signal in the memory.
In the foregoing scheme, optionally, the thermal signal buffering unit may include:
the hot signal buffer subunit is used for buffering the hot signals in the queue and buffering the queue in the memory; wherein the buffer amount of the queue is less than or equal to a preset value.
In the foregoing solution, optionally, the apparatus for acquiring network data may further include:
and the thermal signal deleting module is used for deleting the thermal signal at the head position in the queue if the current buffer amount of the queue is equal to a preset numerical value.
According to the network data acquisition device provided by the third embodiment of the disclosure, the cache condition judgment module can determine whether the trigger event meets the preset cache condition when the trigger event for sending the network request is detected on the current display page; the network data acquisition module can directly acquire the network data corresponding to the network request from the cached data without sending the network request to the server again if the network request is satisfied, namely the cached data on the client comprises the network data corresponding to the network request; the network data request module may implement that if the network data is not satisfied, that is, the network data corresponding to the network request is not included in the cached data on the client, a network request needs to be sent to the server to obtain the network data corresponding to the network request. The device can directly acquire the network data from the cached data when the same display page or other display pages are switched to acquire the same network data again, and the network request does not need to be repeatedly sent to the server, so that the frequency of sending the network request by the client is reduced, and the network flow is saved.
The device for acquiring network data provided by the embodiment of the disclosure can execute the method for acquiring network data provided by any embodiment of the disclosure, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, in the embodiment of the apparatus for acquiring network data, each unit and each module included in the apparatus are only divided according to functional logic, but are not limited to the above division as long as the corresponding function can be implemented; in addition, specific names of the functional units are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the present disclosure.
Example four
Referring now to fig. 4, a block diagram of a terminal device 800 suitable for use in implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The terminal device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 4, the terminal device 800 may include a processing means (e.g., a central processing unit, a graphic processor, etc.) 801 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)802 or a program loaded from a storage means 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data necessary for the operation of the terminal apparatus 800 are also stored. The processing apparatus 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
Generally, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage 808 including, for example, magnetic tape, hard disk, etc.; and a communication device 809. The communication means 809 may allow the terminal apparatus 800 to perform wireless or wired communication with other apparatuses to exchange data. While fig. 4 illustrates a terminal apparatus 800 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
EXAMPLE five
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer storage medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 809, or installed from the storage means 808, or installed from the ROM 802. The computer program, when executed by the processing apparatus 801, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer storage media described above in this disclosure can be computer readable signal media or computer readable storage media or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer storage medium that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer storage medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer storage medium may be contained in the terminal device; or may exist separately without being assembled into the terminal device.
The computer storage medium carries one or more programs that, when executed by the terminal device, cause the terminal device to: when a trigger event for sending a network request is detected on a current display page, determining whether the trigger event meets a preset cache condition; if so, acquiring network data corresponding to the network request from the cached data; if not, sending a network request to the server to acquire network data corresponding to the network request.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present disclosure may be implemented by software or hardware. For example, the cache condition determining module may be further described as "determining whether the trigger event satisfies the preset cache condition when the trigger event for sending the network request is detected on the current display page".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.

Claims (8)

1. A method for acquiring network data is characterized by comprising the following steps:
when a trigger event for sending a network request is detected on a current display page, determining whether the trigger event meets a preset caching condition;
if so, acquiring network data corresponding to the network request from the cached data;
if not, sending the network request to a server to acquire network data corresponding to the network request;
converting a cold signal corresponding to the network request into a hot signal, and caching the hot signal, wherein the cold signal is repackaged of the network request and can only be used for requesting network data corresponding to the network request, the hot signal is a result of converting the cold signal, and the cached hot signal includes the network data corresponding to the network request;
if so, acquiring the network data corresponding to the network request from the cached data comprises:
if the network data corresponding to the network request is included in the cached thermal signal, acquiring the network data corresponding to the network request from the cached thermal signal;
the buffering the thermal signal, comprising: and buffering the thermal signal in a memory.
2. The method of claim 1, wherein if not, sending the network request to a server to obtain network data corresponding to the network request comprises:
if the triggering event is the first triggering, or the triggering event is the second triggering and the network data corresponding to the network request is not included in the cached thermal signal, sending the network request to a server to acquire the network data corresponding to the network request.
3. The method of claim 1, further comprising:
and when the triggering operation of entering the current display page is detected, packaging each network request involved in the current display page into the cold signal respectively.
4. The method of claim 3, wherein the buffering the thermal signal in a memory comprises: buffering the thermal signal in a queue, and buffering the queue in a memory; and the buffer amount of the queue is less than or equal to a preset value.
5. The method of claim 4, further comprising, prior to said buffering said thermal signal in a queue: and if the current buffer amount of the queue is equal to the preset value, deleting the thermal signal at the head position of the queue in the queue.
6. An apparatus for acquiring network data, comprising:
the cache condition judging module is used for determining whether the trigger event meets the preset cache condition or not when the trigger event for sending the network request is detected on the current display page;
the network data acquisition module is used for acquiring the network data corresponding to the network request from the cached data if the network request is received;
the network data request module is used for sending the network request to a server to acquire network data corresponding to the network request if the network request is not received;
a hot signal buffer module, configured to convert a cold signal corresponding to the network request into a hot signal, and buffer the hot signal, where the cold signal is a repackaged of the network request and can only be used to request network data corresponding to the network request, the hot signal is a result of converting the cold signal, and the buffered hot signal includes the network data corresponding to the network request;
the network data acquisition module is specifically configured to:
if the network data corresponding to the network request is included in the cached thermal signal, acquiring the network data corresponding to the network request from the cached thermal signal;
the thermal signal buffer module comprises:
and the heat signal caching unit is used for caching the heat signal in a memory.
7. A terminal device, characterized in that the terminal device comprises:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the method of acquiring network data of any one of claims 1-5.
8. A computer-readable storage medium, on which a computer program is stored, the computer program, when being executed by a processor, implementing the method for acquiring network data according to any one of claims 1 to 5.
CN201910554535.6A 2019-06-25 2019-06-25 Method, device, equipment and storage medium for acquiring network data Active CN110300163B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910554535.6A CN110300163B (en) 2019-06-25 2019-06-25 Method, device, equipment and storage medium for acquiring network data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910554535.6A CN110300163B (en) 2019-06-25 2019-06-25 Method, device, equipment and storage medium for acquiring network data

Publications (2)

Publication Number Publication Date
CN110300163A CN110300163A (en) 2019-10-01
CN110300163B true CN110300163B (en) 2022-04-22

Family

ID=68028873

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910554535.6A Active CN110300163B (en) 2019-06-25 2019-06-25 Method, device, equipment and storage medium for acquiring network data

Country Status (1)

Country Link
CN (1) CN110300163B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107491320A (en) * 2017-06-26 2017-12-19 北京五八信息技术有限公司 Loading method and device based on mixed mode Mobile solution
CN108153783A (en) * 2016-12-06 2018-06-12 腾讯科技(北京)有限公司 A kind of method and apparatus of data buffer storage

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9229867B2 (en) * 2011-06-16 2016-01-05 International Business Machines Corporation Shared network response cache
CN106909690A (en) * 2017-03-07 2017-06-30 四川驹马企业管理有限公司 Network data caching method
US10659556B2 (en) * 2017-05-16 2020-05-19 Sap Se Progressive hybrid web application
CN108563470A (en) * 2018-03-06 2018-09-21 北京酷我科技有限公司 The loaded and optimized strategy of web page under a kind of iOS

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108153783A (en) * 2016-12-06 2018-06-12 腾讯科技(北京)有限公司 A kind of method and apparatus of data buffer storage
CN107491320A (en) * 2017-06-26 2017-12-19 北京五八信息技术有限公司 Loading method and device based on mixed mode Mobile solution

Also Published As

Publication number Publication date
CN110300163A (en) 2019-10-01

Similar Documents

Publication Publication Date Title
CN111581563B (en) Page response method and device, storage medium and electronic equipment
CN111488185B (en) Page data processing method, device, electronic equipment and readable medium
CN112272226B (en) Picture loading method and device and readable storage medium
CN111273999B (en) Data processing method and device, electronic equipment and storage medium
WO2021082600A1 (en) Webpage image monitoring method and apparatus, electronic device, and computer readable storage medium
CN112379982B (en) Task processing method, device, electronic equipment and computer readable storage medium
CN111432001A (en) Method, apparatus, electronic device, and computer-readable medium for jumping scenes
CN110633434A (en) Page caching method and device, electronic equipment and storage medium
CN113760536A (en) Data caching method and device, electronic equipment and computer readable medium
CN109697034B (en) Data writing method and device, electronic equipment and storage medium
CN111309496A (en) Method, system, device, equipment and storage medium for realizing delay task
CN111163336A (en) Video resource pushing method and device, electronic equipment and computer readable medium
CN110300163B (en) Method, device, equipment and storage medium for acquiring network data
CN113727172B (en) Video cache playing method and device, electronic equipment and storage medium
CN111444457B (en) Data release method and device, storage medium and electronic equipment
WO2021082599A1 (en) Wed page image monitoring method and device, electronic equipment and computer readable storage medium
CN114861106A (en) Information processing method, device, electronic equipment and storage medium
CN111240758A (en) Material display method and device, electronic equipment and storage medium
CN112163176A (en) Data storage method and device, electronic equipment and computer readable medium
CN110633141A (en) Memory management method and device of application program, terminal equipment and medium
CN115225586B (en) Data packet transmitting method, device, equipment and computer readable storage medium
CN111258670B (en) Method and device for managing component data, electronic equipment and storage medium
CN111258777B (en) Method, device, system, equipment and storage medium for transmitting voice data
CN112948108B (en) Request processing method and device and electronic equipment
WO2022206474A1 (en) Data acquisition method and apparatus, electronic 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
GR01 Patent grant
GR01 Patent grant