Disclosure of Invention
In view of the above, the present invention is directed to a method for preloading a client, so as to reduce the loading time.
Another objective of the present invention is to provide a client preloading device, which reduces the loading time.
In order to achieve the above object, the present invention provides a client preloading method, including:
the method comprises the steps of obtaining the use behavior characteristics of a user in each scene in advance;
acquiring user use behavior characteristics corresponding to a current scene of a user, and calculating a pre-loading required value corresponding to each operation of the user in the current scene according to a preset prediction strategy;
acquiring loading data required by a switching scene, wherein the switching scene is a scene corresponding to an operation in which a preloading requirement value exceeds a preset preloading requirement threshold;
and monitoring scene switching of the user, determining that the switched scene is matched with a scene corresponding to the acquired loading data, and displaying the acquired loading data.
The statistical user usage behavior characteristics include:
respectively counting the use behavior characteristics of each user by taking the user as an identifier; or
And counting the use behavior characteristics of all the users, and acquiring the average value of the use behavior characteristics of all the users as the use behavior characteristics of the users.
Before obtaining the user usage behavior characteristics corresponding to the current scene of the user, the method further includes:
the client ranks the first use behavior characteristics of the user, selects a preset number of scenes before ranking, pulls the loading data required by the preset number of scenes to form a loading data set and stores the loading data set;
and determining that the current scene is the scene browsed by the user for the first time, and inquiring and acquiring the loading data corresponding to the current scene from the pre-stored loading data set and displaying the loading data.
The user usage behavior characteristics include: a temporal characteristic and an operational characteristic, wherein,
the temporal characteristics include: the mean value and the mean square error of the residence time of the user in different scenes;
the operational characteristics include a probability of a user switching from one scene to another.
The calculating the pre-loading required value corresponding to each operation of the user in the current scene according to the preset prediction strategy comprises the following steps:
calculating the average weight of the stay time of the user in the current scene through a preset average weight calculation function, and multiplying the average weight by an average weight coefficient;
calculating the mean square error weight of the residence time of the user in the current scene through a preset mean square error weight calculation function, and multiplying the mean square error weight by a mean square error weight coefficient;
calculating the probability weight of the user for executing operation switching to the switching scene under the current scene through a preset probability weight calculation function, and multiplying the probability weight by a probability weight coefficient; or calculating the probability weight of the user in the current scene through the switched scene and then switching the scene through a preset probability weight calculation function, and multiplying the probability weight by the probability weight coefficient and the predicted layer number power of the attenuation factor; and
and adding the multiplied products to obtain a preloading required value corresponding to the operation executed by the user in the current scene.
After the step of multiplying by the probability weight coefficient, further comprising:
calculating the weight of the pull time estimation value corresponding to the loaded data required by switching to a switching scene after the user performs operation in the current scene through a preset pull time estimation value weight calculation function, multiplying the weight of the pull time estimation value by a pull time estimation value weight coefficient, and performing the step of adding the multiplied products;
after the step of multiplying by the probability weight coefficient and the predicted number of layers of the attenuation factor, further comprising:
and multiplying the sum of the acquired time estimation values of the loading data required by the passing scene from the current scene to the last switching scene by the pull time estimation value weight coefficient and the predicted layer number power of the attenuation factor, and executing the step of adding the multiplied products.
The acquiring of the loading data required for switching the scenes comprises:
inquiring a pre-stored loading data set, and if loading data required by scene switching exists and the loading data is the latest, acquiring the loading data required by the scene switching from the loading data set; if not, then,
sending a data acquisition request to a server, pulling loading data required by a switching scene corresponding to an operation of which the preloading requirement value exceeds a preset preloading requirement threshold value from the server, and storing the loading data in a loading data set; or sending a data preparation request to the server, receiving the data preparation request by the server, inquiring and acquiring the loading data required by the switching scene, and packaging the loading data.
Further comprising:
and when the difference between the current timestamp and the timestamp of the loaded data is greater than a preset time updating threshold, the client actively pulls the corresponding loaded data to the server and updates the stored loaded data.
Further comprising:
and determining that the switched scene is not matched with the scene corresponding to the acquired loading data, interrupting the preloading data which is transmitted, and pulling the loading data required by the switched scene from the server.
Further comprising:
and determining the user exit scene, and updating the stored use behavior characteristics of the user under each scene according to the user scene switching.
A client preloading device, the device comprising: a usage behavior characteristic statistics module, a preload requirement value calculation module, a preload data acquisition module, and a scenario matching module, wherein,
the using behavior characteristic counting module is used for acquiring the using behavior characteristics of the user in each scene;
the pre-loading required value calculation module is used for acquiring the user use behavior characteristics corresponding to the current scene of the user and calculating the pre-loading required value corresponding to each operation of the user in the current scene according to a preset prediction strategy;
the system comprises a preloading data acquisition module, a pre-loading data acquisition module and a pre-loading data acquisition module, wherein the preloading data acquisition module is used for acquiring loading data required by a switching scene, and the switching scene is a scene corresponding to an operation in which a pre-loading requirement value exceeds a pre-set pre-loading requirement threshold;
and the scene matching module is used for monitoring scene switching of the user, determining that the switched scene is matched with the scene corresponding to the acquired loading data, and displaying the acquired loading data.
The preload requirement value calculation module includes: a mean weight calculation unit, a mean square error weight calculation unit, a probability weight calculation unit, and a preload requirement value calculation unit, wherein,
the average weight calculation unit is used for calculating the average weight of the stay time of the user in the current scene through a preset average weight calculation function;
the mean square error weight calculation unit is used for calculating the mean square error weight of the stay time of the user in the current scene through a preset mean square error weight calculation function;
the probability weight calculation unit is used for calculating the probability weight of the user for executing operation switching to the switching scene under the current scene through a preset probability weight calculation function;
and the pre-loading required value calculating unit multiplies the average weight calculated by the average weight calculating unit by the average weight coefficient, multiplies the mean square error weight calculated by the mean square error weight calculating unit by the mean square error weight coefficient, multiplies the probability weight calculated by the probability weight calculating unit by the probability weight coefficient, and adds the products of the multiplications.
The scene matching module includes: a monitoring unit, a scene matching unit, a loading data set unit and a loading data display unit, wherein,
the monitoring unit is used for monitoring user scene switching and outputting the monitored user scene switching information to the scene matching unit;
the scene matching unit is used for receiving the user scene switching information, matching the scene corresponding to the loading data stored in the loading data set unit, and outputting the matched switching scene information to the loading data display unit if the scene is matched with the scene;
and the loading data display unit acquires the loading data required by the scene switching from the loading data set unit and displays the loading data according to the received scene switching information.
The scene matching module further comprises: an interrupt unit and a load data pull unit, wherein,
the scene matching unit is further used for outputting unmatched switching scene information to the interruption unit when the received user scene switching information is unmatched with the scene corresponding to the loading data stored by the loading data set unit;
the interruption unit is used for interrupting the preloading data which is transmitted according to the received switching scene information and sending a notification message to the loading data pulling unit;
and the loading data pulling unit receives the notification message and pulls the loading data required by the scene switching from the server.
As can be seen from the foregoing technical solutions, the client preloading method and the client preloading device provided in the embodiments of the present invention count and store the usage behavior characteristics of the user in each scene in advance; acquiring user use behavior characteristics corresponding to a current scene of a user, and calculating a pre-loading required value corresponding to each operation of the user in the current scene according to a preset prediction strategy; acquiring loading data required by a switching scene corresponding to an operation in which the preloading requirement value exceeds a preset preloading requirement threshold; and monitoring scene switching of the user, determining that the switched scene is matched with a scene corresponding to the acquired loading data, and displaying the acquired loading data. Therefore, the use behavior characteristics of the user in each scene are counted and stored in advance, the subsequent operation of the user is predicted according to the use behavior characteristics of the user in the current scene, and the loading data required by the predicted scene is acquired and preloaded in the process that the user browses the current scene, so that the loading time of the client is shortened when the user switches to the predicted scene.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail with reference to the accompanying drawings and specific embodiments.
The existing client-side preloading method adopts an on-demand or experience preloading mode or a picture rolling preloading mode, and when a multi-scene is switched, the client-side needs to pull required loading data from a server, so that the loading time is long, and the personalized loading requirement of a user cannot be met. In practical applications, the usage behavior of each user is different for different scenes, that is, the time that the user stays in different scenes may be different, and the probability of switching from one scene to a different scene is also different. In the embodiment of the invention, user using behaviors of a user in different scenes are considered, namely the staying time (browsing time) of the user in the scenes and the probability of executing different operations to jump to the corresponding scenes in the different scenes, a client preloading method based on statistical prediction is provided, the probability of entering another scene when the user executes a certain operation in the current scene is predicted according to the mean value and the mean square difference of the browsing time of the user in the different scenes and the probability of executing different operations to jump to the corresponding scenes in the different scenes, so that whether the browsing time of the user in the current scene is needed to be utilized or not is judged, and the data needed by entering the next scene is preloaded, so that the user does not need to wait for the time for acquiring the data from a server when entering the next scene.
It should be noted that the scene switching according to the embodiment of the present invention includes: jumping between pages, calling or switching between different scenes, switching between different small scenes in a scene (e.g., tab label switching, upper and lower page switching, etc.), switching of picture browsing, jumping of link information, and the like.
Fig. 1 is a statistical diagram illustrating user usage behavior characteristics according to an embodiment of the present invention. Referring to fig. 1, the user usage behavior characteristics include: the time characteristic is represented by user stay time, and the operation characteristic is represented by the probability of switching from one scene to another scene by a user, and each scene can correspond to one website page.
Statistically, the user stays under the scene C1 for up to 20s for browsing the content in the scene C1. Meanwhile, under scenario C1, operation Q is performed with a probability of up to 60%, respectively1Jump from scene C1 to scene C2, with 20% probability, to perform operation Q2Jump from scene C1 to scene C3, with 10% probability, to perform operation Q3Jump from scene C1 to scene C4, and, 10% probability of performing operation Q4Exit from scenario C1;
under scene C2, stay for 10s for browsing the content in scene C2;
under scene C3, stay for 5s for browsing the content in scene C3;
under scene C4, a stay time of 2s is used to browse the content in scene C4.
In the embodiment of the present invention, it is considered that when a user jumps from the scene C1 to the scene C2, the loaded data required to jump from the scene C1 to the scene C2 may be sent to the server through the client during the process of browsing the scene C1 by the user, the server responds to the data acquisition request, and transmits the required loaded data (the loaded data required by the scene C2) to the client, or triggers to package the loaded data required to jump from the scene C1 to the scene C2 from the cache. Thus, by this preloading manner, when the user is about to enter the scene C2 from the scene C1, the data of the scene C2 can be directly presented without waiting for the data to be loaded.
Fig. 2 is a schematic flowchart of a client preloading method according to an embodiment of the present invention. Referring to fig. 2, the process includes:
step 201, counting and storing the use behavior characteristics of the user in each scene in advance;
in this step, in order to enable the technical solution of the embodiment of the present invention to realize accurate prediction and make an effective preloading decision, statistics needs to be performed on the usage behavior characteristics of the user at the client.
User usage behavior characteristics include: a temporal characteristic and an operational characteristic, wherein,
the time characteristics mainly include: average of user stay time in different scenesAnd a mean square error σ. Wherein,for reflecting the average characteristics of the user's dwell time in the scene, while σ is used to reflect the stability of the dwell time when the user visits the same scene at different times. Of course, in practical applications, the content included in the time characteristic may also be changed according to different applications and types of information that can be obtained.
FIG. 3 is a statistical diagram of the temporal characteristics according to an embodiment of the present invention. Referring to fig. 3, a scene C entered by a user is acquired1~CnCounting the first time the user enters the scene CiResidence time T oflAccording to TlObtaining user entry scenario CiAverage value of residence time ofAnd mean square error σiWherein n, l and i are natural numbers, i is more than or equal to 1 and less than or equal to n,
in the formula,
m is a user entry scenario CiThe total number of times.
The operation characteristics are used for representing the probability of the user switching from one scene to another scene, and mainly comprise the user in the scene CiDown performs operation QkTo switch to another scene CjCan be expressed as p (Q)k,Cj/Ci) Where k, j is a natural number, in practical application, if the scene to which the same operation is performed in the same scene is not changed, the scene C is selectediSwitch to scene CjCan be expressed as p (Q)k/Ci)=p(Cj/Ci)。
When the user use behavior characteristics are counted, a global counting mode can be adopted, namely the use behavior characteristics of all users are taken as counting objects, and the obtained counting results are applied to all users; or a personalized statistical mode can be adopted, namely the use behavior characteristics of a single user are taken as statistical objects, and the obtained statistical result is applied to the user; and a statistical mode combining the two modes can be adopted, namely, firstly, an effective global user use behavior statistical characteristic is obtained through the global statistical mode, the statistical characteristic result is used as an initialization value of the use behavior characteristics of all users, then, the personalized statistical mode is started, and the statistical characteristic result used as the initialization value is corrected according to the use behavior of the user. That is, the statistical user usage behavior characteristics include:
respectively counting the use behavior characteristics of each user by taking the user as an identifier;
in the step, the clients can be taken as a statistical unit, and each client respectively counts the use behavior characteristics of each user contained in the client, so that network resources are not consumed; or after each client respectively counts the usage behavior characteristics of each user included in the client, the usage behavior characteristics of each user are reported to the server, and the server averages the usage behavior characteristics of the same user reported by each client as the usage behavior characteristics of the user and sends the usage behavior characteristics to each client for storage.
Or,
and counting the use behavior characteristics of all the users, and acquiring the average value of the use behavior characteristics of all the users as the use behavior characteristics of the users.
In this step, after the client counts the usage behavior characteristics of all users included in the client, the server reports the total usage behavior characteristics of all users to the server, and the server averages the total usage behavior characteristics reported by each client according to the number of users, and sends the average usage behavior characteristics as the usage behavior characteristics of the users to each client for storage.
Step 202, acquiring user use behavior characteristics corresponding to a current scene of a user, and calculating a pre-loading required value corresponding to each operation of the user in the current scene according to a preset prediction strategy;
in this step, if the current scene is a scene that the user browses for the first time, before obtaining the user usage behavior characteristic corresponding to the current scene of the user, the method further includes:
and determining that the current scene is the scene browsed by the user for the first time, inquiring and acquiring the loading data corresponding to the current scene from the pre-stored loading data set, and displaying. That is to say, after the use behavior characteristics of the user in each scene are obtained through statistics by the client, the use behavior characteristics of the user for the first time are sorted, the scenes with the preset number before sorting are selected, the loading data required by the scenes with the preset number are pulled, a loading data set is formed and stored, and after the current scene is determined to be the scene browsed by the user for the first time, the loading data corresponding to the current scene is inquired and obtained from the pre-stored loading data set and displayed. In this way, the loading time of the client can be effectively reduced.
When a user browses a current scene, it is required to determine whether data required by a scene subsequently switched by the user needs to be preloaded, that is, preloading requirement detection is performed, so that waiting time of the user when switching the scene and loading time of a client are reduced.
In the embodiment of the invention, the preloading requirement detection is carried out according to the using behavior characteristics of the user, and in the scheme, the condition of meeting the preloading requirement, namely the preloading requirement value of the user under the current scene, which is calculated according to the preset scoring strategy, comprises two aspects: on one hand, the stay time of the user in the current scene is long enough, and if the stay time is short, the reduction effect of preloading on the loading time is not great; on the other hand, the switching prediction of the scene to be switched has higher credibility, and if the credibility of the switching prediction is lower, the actual switched scene is inconsistent with the predicted switching scene, so that the preloaded data is unavailable, and unnecessary network flow overhead is increased.
For the condition that the stay time of the user in the current scene is long enough, the average value of the stay time of the current scene can be calculatedThe mean square error sigma is determined, and the condition with higher credibility for the switching prediction of the scene to be switched can be executed in the current sceneProbability p (Q) of switching to corresponding scene by different operationsk/Ci) To determine, thus, synthesizeσ and p (Q)k/Ci) It can be calculated whether the preload requirement values of the users of different operations that may be performed under the current scenario satisfy the preload requirement.
In the embodiment of the invention, two processing mechanisms for calculating the preload requirement value are provided, namely a prediction strategy comprises the following steps: single-layer prediction strategies and multi-layer prediction strategies.
1) Single layer prediction strategy
The single-layer prediction strategy refers to calculating the preload requirement value of the user in the current scene only by considering the residence time characteristics (mean value and mean square error of the residence time) of the user in the current scene and the probability of switching to the corresponding scene when all operations are performed in the current scene. Under this mechanism, the scenario that meets the preloading requirement must be satisfied to be able to switch directly from the current scenario.
In the embodiment of the invention, a linear weighting method is adopted to calculate the scene CiThe preload requirement value of the following user can be calculated by an exponential weighting method or other nonlinear weighting methods, and the linear weighting method is calculated according to the following formula:
in the formula,
pexkis that the user is in the current scene CiLower execution operation QkSwitch to scene CjA preload requirement value;
representing the current scene C of the user calculated by the mean weight calculation functioniAverage weight of dwell time of (a);
wσ(σi) Representing the current scene C of the user calculated by a mean square error weight calculation functioniThe mean square error weight of the dwell time of,and wσ(σi) Can be determined according to actual needs;
wo(p(Qk/Ci) Representing the current scene C of the user calculated by the probability weight calculation functioniLower execution operation QkSwitch to scene CjA probability weight of (d);
α, β, γ are the respective mean weight coefficient, mean square error weight coefficient, and probability weight coefficient, and preferably α + β + γ may be set to 1.
In practical applications, an estimated time spent on pulling load data of a scene (switched scene) which may appear next time can be taken as a basis for calculating the preloading requirement, and the estimated time spent on loading the data can be given empirically or set through statistical conditions of previous operations, so that the formula (1) can be modified as follows:
in the formula,
w(Lj) Indicating the presence of a user calculated by a weight calculation function for pulling a time estimateFront scene CiLower execution operation QkThen will enter scene Cj(switched scene) the weight of the pull time estimation value corresponding to the data to be loaded;
xi is the corresponding weight coefficient of the pull time estimation value.
LjThe impact of the size of (c) on the preload requirement calculation depends on the particular application.
2) Multi-layer prediction strategy
The multi-layer prediction strategy refers to considering not only the stay time characteristics of the user in the current scene and the probability (operation characteristics) of performing all operations to switch to the corresponding scene in the current scene, but also the time characteristics and operation characteristics of scenes (switched scenes) that may appear in the future. Under the mechanism, the scenes meeting the preloading requirements can be directly switched from the current scenes, and also include scenes which cannot be directly reached by the current scenes but can be reached by the switched scenes. The above equations (1) and (2) are modified respectively in consideration of the time characteristic and the operation characteristic of the switched scene, and are converted into corresponding equations (3) and (4), respectively as follows:
in the formula,
p(Cj/Ci) Representing a scene from a current scene CiSwitching to the scene C through the switched scenejThe probability of (d);
n represents the predicted number of layers;
lambda is attenuation factor, 0 < lambda < 1, lambda is introducednTo gradually diminish the likelihood of deeper prediction scenarios being preloaded;
representing a slave scene CiTo scene CjThe sum of the estimated values of the acquisition time of the loaded data required for passing through the scene.
Step 203, acquiring loading data required by a switching scene corresponding to an operation in which the preloading requirement value exceeds a preset preloading requirement threshold;
in this step, load data required for switching a scenario is obtained, where the scenario to be switched is a scenario corresponding to an operation in which the preload demand value exceeds a preset preload demand threshold, specifically, if:
pexk>pththen, the current scene C of the user is obtainediLower execution operation QkSwitch to scene CjThe required load data.
In the formula,
pthis toA preload requirement threshold is set first.
When any operation corresponds to the pre-load demand valueGreater than pthWhen it is considered to meet the pre-load requirement, pthThe larger the value, the more rigorous the calculation of the preload requirement is indicated, and the lower the probability of performing the preload.
Acquiring loading data required by a switching scene corresponding to an operation in which the preload requirement value exceeds a preset preload requirement threshold value, wherein the loading data comprises:
inquiring a pre-stored loading data set, and if loading data required by scene switching exists and the loading data is the latest, acquiring the loading data required by the scene switching from the loading data set; if not, then,
sending a data acquisition request to a server, pulling loading data required by a switching scene corresponding to an operation of which the preloading requirement value exceeds a preset preloading requirement threshold value from the server, and storing the loading data in a loading data set; or, sending a data preparation request to the server, receiving the data preparation request by the server, inquiring and acquiring the loading data required by the scene switching, and packaging the loading data to reduce the network transmission amount as much as possible.
And determining whether the loaded data is latest according to the timestamp information for storing the loaded data and the current timestamp information, and if the difference between the current timestamp and the timestamp of the loaded data is not greater than a preset time updating threshold value, determining that the loaded data is latest. In practical application, when the difference between the current timestamp and the timestamp of the loaded data is greater than the preset time update threshold, the client actively pulls the corresponding loaded data from the server and updates the stored loaded data.
Fig. 4 is a schematic view of scene operation characteristics according to an embodiment of the present invention. Referring to fig. 4, it is assumed that the users have a probability of 60% after entering the scene C1, respectively, by performing the operation Q1Switch to scenario C2 with a 20% probability by performing operation Q2Switch to scenario C3 with a probability of 10% by performing operation Q3Switch to scenario C4 with a probability of 10% by performing operation Q8Withdrawing; in scenario C2, the operation Q is performed with a probability of 90%, respectively4Switch to scenario C5 with a probability of 10% by performing operation Q5Switch to scene C6; in scenario C6, the operation Q is performed with a probability of 50%, respectively6Switch to scenario C3 with a 50% probability by performing operation Q7Switching to the scene C4, it is thus predicted that, under the current scene C1, a user will enter the scene C5 with a probability of 54%, enter the scene C6 with a probability of 6%, enter the scene C3 with a probability of 20%, enter the scene C4 with a probability of 10%, exit with a probability of 10%, and if α ═ β ═ 0 and the preset preload requirement threshold is 50%, by using multi-layer prediction (setting the maximum number of layers to be 2), when the user enters the scene C1, the scene C5 will be entered into the scene C, exit with a probability of 6%, and if the user enters the scene C1, the scene C1 will be predictedBoth C2 and C5 are able to meet the preload requirement.
Step 204, monitoring the scene switching of the user, determining that the switched scene is matched with the scene corresponding to the acquired loading data, and displaying the acquired loading data.
In this step, if the user switches the current scene by performing an operation, the switched scene corresponding to the performed operation is acquired, and it is determined whether the switched scene matches the scene corresponding to the acquired load data, and if so, the pulled load data is displayed.
In the embodiment of the present invention, the obtained loading data includes: the load data stored in the load data set and the load data acquired in step 203 are stored in advance.
As mentioned above, in step 203, if the data preparation request is sent to the server, the displaying the obtained load data includes:
and sending a data acquisition request to a server, receiving the data acquisition request by the server, and sending the packaged loading data to the client for display.
The steps further include:
and determining that the switched scene is not matched with the scene corresponding to the acquired loading data, interrupting the preloading data which is being transmitted, pulling the loading data required by the switched scene from the server, or interrupting the preloading data which is being transmitted and deleting the completed preloading data, and pulling the loading data required by the switched scene from the server.
Further, the method further comprises:
step 205, determining that the user exits from the scene, and updating the stored use behavior characteristics of the user in each scene according to the user scene switching.
In this step, when the user exits from the scene, the user usage behavior characteristics under the corresponding stored scene are respectively updated according to the time characteristics and the operation characteristics of the user in each scene, for example, the mean value and the mean square error of the staying time are recalculated.
Fig. 5 is a schematic flowchart of a client preloading method according to an embodiment of the present invention. Referring to fig. 5, the process includes:
step 501, entering a new scene;
step 502, performing preloading requirement detection;
in this step, the user usage behavior characteristics corresponding to the new scene are obtained, and the pre-loading required value corresponding to each operation of the user in the new scene is calculated according to the user usage behavior characteristics.
Step 503, judging whether to trigger preloading, if so, executing step 504, otherwise, executing step 521;
in this step, according to the detected preload requirement, that is, the calculated preload requirement value corresponding to each operation of the user in the new scene, it is determined whether a preset preload requirement threshold is met, and if so, preload is triggered.
Step 504, starting preloading;
step 505, judging whether the user executes the prediction operation, if so, executing step 506, otherwise, executing step 511;
in this step, the user may set whether to perform the prediction operation during the scene switching, and if the prediction operation is performed, load data required by the scene corresponding to the prediction operation is pulled from the server and stored in the process of browsing the current scene by the user.
Step 506, acquiring required loading data from the stored loading data set;
step 507, entering a next new scene, and returning to execute the step 502;
in this step, the client displays the acquired loading data to the user according to the operation of the user.
Further, the client acquires link information (scene) corresponding to the user operation, matches the link information (scene) corresponding to the acquired loading data, displays the acquired loading data to the user if the matching is successful, and processes the loading data according to the existing flow if the matching is unsuccessful, namely, sends a request to the server to pull the loading data required by the link information corresponding to the user operation.
Step 511, starting interruption invalid preloading;
in this step, if the user does not perform the prediction operation, that is, the operation performed by the user is inconsistent with the predicted operation, it is necessary to interrupt the preloaded data being transmitted, that is, to invalidate the preloading.
Step 512, acquiring the required loading data from the server or the cache;
step 513, entering a next new scene, and returning to execute step 502;
in this step, the entered new scene is different from the scene corresponding to the prediction operation.
Step 521, executing operation and switching scenes;
step 522, enter the next new scenario, and return to step 502.
Next, the loading data required for acquiring the switching scenario corresponding to the operation in which the preload requirement value exceeds the preset preload requirement threshold will be described in detail.
Fig. 6 is a schematic view illustrating a flow of acquiring load data required for switching scenes according to an embodiment of the present invention. Referring to fig. 6, the process includes:
601, obtaining a new task from a preloading task waiting queue;
in this step, if a plurality of preload requirement values exceed a preset preload requirement threshold, the plurality of switching scenarios are corresponded, the plurality of switching scenarios form a preload task waiting queue, and each switching scenario corresponds to a new task.
Step 602, determining whether there is loaded data required by the new task in the completed preloading list or in the cache (loaded data set), if yes, executing step 603, otherwise, executing step 604;
step 603, packaging and returning the required loading data, and executing step 605;
step 604, requesting the server to return the loading data required by the new task;
step 605, adding the returned loading data into a preloading completion list;
step 606, judging whether the preloading task waiting queue is empty, if so, ending the process, otherwise, returning to the step 601.
The interrupt invalid preload is explained below.
When the operation performed by the user is inconsistent with the predicted operation, the data which is preloaded previously may have no effect on the currently entered scene, and when the user performs the operation to switch scenes, two situations may occur: the previously preloaded data is still being transmitted and the transmission of the previously preloaded data has been completed. For the first case, if no intervention is performed on the previously preloaded data, the client needs to wait for the completion of the transmission of the previously preloaded data and then load the loaded data required by the current entering scenario. In the second case, although there is no impact on the loading delay of the data required by the current entering scene, the data preloaded at the previous time may cause two problems: the method includes that a certain memory space is occupied and dirty data is contained, the dirty data refers to data which exists physically but does not exist logically, for example, in a preloading process, a front end performs insertion, deletion or updating operation, so that cached data changes, but the data is not written into a disk or a data file.
FIG. 7 is a flow chart illustrating an embodiment of break-invalidate preloading. Referring to fig. 7, interrupting the invalid preload includes: interrupting the ongoing invalid preloading and deleting the data which has completed the preloading, wherein the flow comprises the following steps:
step 701, judging whether an ongoing preloading task exists, if so, executing step 702, otherwise, executing step 703;
step 702, determining the preloading task needing to be interrupted in the tasks being preloaded, executing interrupt processing on the preloading task needing to be interrupted, and executing step 703;
in this step, the preloading task that needs to be interrupted should satisfy any of the following conditions:
condition 1: the residual loading time of the preloading task needing to be interrupted is too long, and the loading of data needed by the scene to be entered is blocked;
in the embodiment of the invention, the initial timestamps are added to all the tasks starting to be preloaded, when the preloading task needs to be interrupted, the loaded time of the preloading task is calculated, the residual loading time of the preloading task is estimated according to the estimated value of the total loading time of the preloading task, if the estimated residual loading time exceeds the preset loading time threshold, the preloading task is interrupted, and the loading time threshold can be set according to the user experience requirements of different applications.
Condition 2: the data that needs to be preloaded for the upcoming scene is less likely to be loaded by the preloading task that needs to be interrupted.
In the embodiment of the invention, the scene to enter is taken as the current scene, and the preloading demand calculation formula is adopted to determine whether the preloading demand weight of the data loaded by the task exceeds the preset preloading demand threshold value pthAnd if not, interrupting the preloading task.
And step 703, determining the data needing to be deleted in the data which is already preloaded, and deleting the data.
In this step, some data that has already been preloaded may not affect the loading of data that is about to enter a scene, but two problems may be caused: firstly, a certain memory space is occupied; secondly, dirty data is included, for example, in the preloading process, the front end performs insertion, deletion or update operations, so that the data stored at the server end changes, and the preloaded data does not perform corresponding changes.
Deleting the data that needs to be deleted includes:
step 1, deleting dirty data which is already preloaded;
in this step, if the pre-loaded dirty data can be inserted, deleted or updated correspondingly, the dirty data does not need to be deleted.
Step 2, calculating whether the preloading demand weight of the data which is already preloaded exceeds a preset loading time threshold value or not by adopting the preloading demand calculation formula, if so, retaining the data, and if not, executing the step 3;
and 3, evaluating whether the memory space occupied by the currently-preloaded data exceeds a tolerance limit (set according to experience), and if so, deleting all data of which the preloading demand weight does not exceed a preset loading time threshold.
As can be seen from the above, the client preloading method in the embodiment of the present invention predicts the subsequent operations of the user according to the usage behavior characteristics of the user in the current scene by counting and storing the usage behavior characteristics of the user in each scene in advance, and obtains the loading data required by the predicted scene for preloading in the process that the user browses the current scene, so that when the user switches to the predicted scene, the corresponding loading data does not need to be obtained from the service area, the loading time of the client is reduced, and the user experience is improved; furthermore, preloading is carried out according to the using behavior characteristics of the user, so that the using habits of the user can be accurately met, and the individual requirements of the user can be met; moreover, the method can be applied to preloading under multi-scene switching.
Fig. 8 is a schematic structural diagram of a client preloading device according to an embodiment of the present invention. Referring to fig. 8, the apparatus includes: a usage behavior characteristic statistics module, a preload requirement value calculation module, a preload data acquisition module, and a scenario matching module, wherein,
the using behavior characteristic counting module is used for counting and storing the using behavior characteristics of the user in each scene;
the pre-loading required value calculation module is used for acquiring the user use behavior characteristics corresponding to the current scene of the user and calculating the pre-loading required value corresponding to each operation of the user in the current scene according to a preset prediction strategy;
the preloading data acquisition module is used for acquiring the loading data required by the switching scene corresponding to the operation of which the preloading requirement value exceeds the preset preloading requirement threshold;
and the scene matching module is used for monitoring scene switching of the user, determining that the switched scene is matched with the scene corresponding to the acquired loading data, and displaying the acquired loading data.
The preload requirement value calculation module includes: a mean weight calculation unit, a mean square weight calculation unit, a probability weight calculation unit, and a preload requirement value calculation unit (not shown in the figure), wherein,
the average weight calculation unit is used for calculating the average weight of the stay time of the user in the current scene through a preset average weight calculation function;
the mean square error weight calculation unit is used for calculating the mean square error weight of the stay time of the user in the current scene through a preset mean square error weight calculation function;
the probability weight calculation unit is used for calculating the probability weight of the user for executing operation switching to the switching scene under the current scene through a preset probability weight calculation function;
and the pre-loading required value calculating unit multiplies the average weight calculated by the average weight calculating unit by the average weight coefficient, multiplies the mean square error weight calculated by the mean square error weight calculating unit by the mean square error weight coefficient, multiplies the probability weight calculated by the probability weight calculating unit by the probability weight coefficient, and adds the products of the multiplications.
The scene matching module comprises: a monitoring unit, a scene matching unit, a load data set unit, a load data presentation unit, an interrupt unit, and a load data pull unit (not shown in the figure), wherein,
the monitoring unit is used for monitoring user scene switching and outputting the monitored user scene switching information to the scene matching unit;
the scene matching unit receives the user scene switching information, matches with the scene corresponding to the loading data stored in the loading data set unit, outputs the matched switching scene information to the loading data display unit if the scene is matched with the scene, and outputs the unmatched switching scene information to the interrupt unit if the scene is not matched with the scene;
the loading data display unit acquires the loading data required by the scene switching from the loading data set unit and displays the loading data according to the received scene switching information;
the interruption unit is used for interrupting the preloading data which is transmitted according to the received switching scene information and sending a notification message to the loading data pulling unit;
and the loading data pulling unit receives the notification message and pulls the loading data required by the scene switching from the server.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.