Page loading method, device, electronic device and computer-readable storage medium

By obtaining user behavior data and using neural networks to dynamically adjust the loading strategy, the limitations of static optimization, insufficient universality and lack of adaptability of front-end performance optimization methods in the existing technology are solved, and the optimal performance optimization effect is achieved to adapt to different scenarios.

CN119782641APending Publication Date: 2025-04-08CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411773101.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

The existing front-end performance optimization methods have limitations, insufficient versatility and lack of adaptability, making it difficult to adapt to different types of Web applications and user scenarios.

Method used

By obtaining user behavior data in the access request initiated by the client, using the initial neural network to determine the appropriate set of loading policies, dynamically adjusting the loading policies to adapt to different scenarios.

Benefits of technology

It realizes dynamic adjustment of loading strategies based on user behavior, provides the optimal performance optimization method to adapt to different scenarios, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782641A_ABST
    Figure CN119782641A_ABST
Patent Text Reader

Abstract

The embodiments of the present invention provide a page loading method, device, electronic device and computer-readable storage medium, which relate to the field of computer technology, and include: obtaining an access request for a target page initiated by a user on a client; the access request includes the user behavior data of the user; determining a first loading strategy set corresponding to the user behavior data for loading the target page based on an initial neural network; the first loading strategy set includes a first loading strategy for various resources in the target page; and sending the first loading strategy set to the client so that the client uses the first loading strategy set to load various resources in the target page. The embodiments of the present invention can dynamically adjust the loading strategy according to different user behaviors, thereby providing an optimal performance optimization method adapted to different scenarios, so that users have the best experience when visiting a website.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a page loading method, a page loading device, an electronic device and a computer-readable storage medium. Background Art

[0002] With the rapid development of Internet technology and the continuous increase in the number of Internet users, the number of web page visits has also shown an explosive growth trend. This means that websites need to handle more requests and provide users with a faster and smoother experience. Therefore, in the highly competitive Internet era, user experience has become one of the key factors that determine the success of a website or application.

[0003] As an important part of user experience, the optimization degree of front-end performance directly affects user satisfaction and retention rate. Therefore, more and more companies and developers begin to pay attention to front-end performance optimization. With the continuous evolution of front-end technologies such as HTML5 (Hyper Text Markup Language), CSS3 (Cascading Style Sheets), and JavaScript, the capabilities of front-end development have been greatly improved. At the same time, the complexity and functional requirements of web pages are also increasing, resulting in a sharp expansion in the size of front-end code and resources. This not only increases the parsing and execution burden of the browser, but also prolongs the loading time of the web page, seriously affecting the user experience. Therefore, how to optimize the front-end code and resources and improve the loading speed and response efficiency of the web page while ensuring functional requirements has become an urgent problem to be solved in the field of front-end development.

[0004] At present, the front-end performance is mainly improved from the following aspects:

[0005] 1. Resource optimization. Use more efficient image formats such as WebP and AVIF to compress and convert images to reduce image size. At the same time, use CSS's Sprite technology to merge multiple small images into one large image to reduce the number of HTTP (Hypertext Transfer Protocol) requests. Resources can also be deployed to servers around the world through a content distribution network (CDN). Users can obtain resources from the server closest to them, speeding up resource loading.

[0006] 2. Cache optimization. When a browser visits a website, it will check whether the relevant resources of the website are already in the local cache. If so, the browser will load the resources directly from the cache instead of requesting them from the server again.

[0007] 3. Rendering optimization: Reduce the number and complexity of DOM (Document Object Model) operations, avoid frequent redrawing and reflow, and improve page rendering efficiency.

[0008] 4. Network optimization. Using the latest version of the HTTP protocol, HTTP / 2 provides higher performance and better efficiency than HTTP / 1.1. HTTP / 2 supports multiplexing, which means that multiple requests can be processed in parallel without queuing one by one like HTTP / 1.1. In addition, HTTP / 2 also uses header compression technology to further reduce the size of requests and responses. Each HTTP request consumes a certain amount of time and resources. Therefore, reducing the number of HTTP requests is also an important strategy for optimizing front-end performance.

[0009] For the current mainstream front-end optimization methods, although each method optimizes the performance of the front-end to a certain extent and does improve the user experience compared to the previous front-end pages, the current optimization methods still have the following problems:

[0010] 1. Limitations of static optimization: Many traditional front-end performance optimization methods are based on static rules or manual settings, such as resource compression, cache settings, etc., which limits the optimization effect.

[0011] 2. Lack of versatility: Some front-end performance optimization methods lack versatility and cannot adapt to different types of web applications and user scenarios. For example, the optimization items for large single-page applications (SPA) and traditional multi-page applications (MPA) may be different, but existing methods are difficult to flexibly adjust to different scenarios.

[0012] 3. Lack of adaptability: Traditional optimization methods lack adaptability. Summary of the invention

[0013] In view of the above problems, embodiments of the present invention are proposed to provide a page loading method, a page loading device, an electronic device and a computer-readable storage medium that overcome the above problems or at least partially solve the above problems.

[0014] In order to solve the above problem, an embodiment of the present invention discloses a page loading method, which includes:

[0015] Obtaining an access request for a target page initiated by a user on a client; the access request includes user behavior data of the user;

[0016] Determine, based on the initial neural network, a first loading strategy set corresponding to the user behavior data and used to load the target page; the first loading strategy set includes first loading strategies for various resources in the target page;

[0017] The first loading strategy set is sent to the client, so that the client adopts the first loading strategy set to load various resources in the target page.

[0018] In one or more embodiments, further comprising:

[0019] When the response time is obtained, determining whether the response time meets the response time threshold; wherein the response time is generated by the client after the target page is loaded;

[0020] If the response time does not meet the response time threshold, generating a second loading strategy set that meets the response time threshold; the second loading strategy set includes second loading strategies for various resources in the target page;

[0021] The initial neural network is trained using the user behavior data and the second loading strategy set to obtain a trained target neural network.

[0022] In one or more embodiments, the initial neural network is generated by:

[0023] Acquire at least one historical user behavior data for the target page;

[0024] Determine the first candidate loading strategy set corresponding to each historical user behavior data, and obtain multiple pairs of historical user behavior data-first candidate loading strategy sets; wherein the response time corresponding to each first candidate loading strategy set meets the response time threshold;

[0025] Divide multiple pairs of historical user behavior data and first candidate loading strategy sets into training sets and test sets;

[0026] The historical user behavior data is used as input, the first candidate loading strategy set is used as output, and the training set and the test set are used to train a preset neural network to obtain a trained initial neural network.

[0027] In one or more embodiments, generating a second loading strategy set that satisfies the response time threshold includes:

[0028] generating at least one second candidate loading strategy set corresponding to the user behavior data;

[0029] Determine the response time corresponding to each second candidate loading strategy set;

[0030] The second candidate loading strategy set with the shortest response time is used as the second loading strategy set.

[0031] In one or more embodiments, the user behavior data includes: client type, network type, resource type, resource size, and resource quantity.

[0032] In one or more embodiments, the loading strategy includes: whether to cache files, whether to compress images, whether to merge files, whether to lazily load, and resource loading priority.

[0033] In one or more embodiments, the type of neural network includes a back-propagation neural network.

[0034] Accordingly, an embodiment of the present invention discloses a page loading device, the device comprising:

[0035] An acquisition module, used to acquire an access request for a target page initiated by a user at a client; the access request includes user behavior data of the user;

[0036] A first determination module is used to determine, based on an initial neural network, a first loading strategy set corresponding to the user behavior data and used to load the target page; the first loading strategy set includes first loading strategies for various resources in the target page;

[0037] The sending module is used to send the first loading strategy set to the client, so that the client adopts the first loading strategy set to load various resources in the target page.

[0038] In one or more embodiments, further comprising:

[0039] A second determination module is used to determine whether the response time satisfies a response time threshold when the response time is acquired; wherein the response time is generated by the client after the target page is loaded;

[0040] A generating module, configured to generate a second loading strategy set satisfying the response time threshold if the response time does not satisfy the response time threshold; the second loading strategy set comprising second loading strategies for various resources in the target page;

[0041] A training module is used to train the initial neural network using the user behavior data and the second loading strategy set to obtain a trained target neural network.

[0042] In one or more embodiments, the training module is further used to:

[0043] Acquire at least one historical user behavior data for the target page;

[0044] Determine the first candidate loading strategy set corresponding to each historical user behavior data, and obtain multiple pairs of historical user behavior data-first candidate loading strategy sets; wherein the response time corresponding to each first candidate loading strategy set meets the response time threshold;

[0045] Divide multiple pairs of historical user behavior data and first candidate loading strategy sets into training sets and test sets;

[0046] The historical user behavior data is used as input, the first candidate loading strategy set is used as output, and the training set and the test set are used to train a preset neural network to obtain a trained initial neural network.

[0047] In one or more embodiments, the generating module is specifically used to:

[0048] generating at least one second candidate loading strategy set corresponding to the user behavior data;

[0049] Determine the response time corresponding to each second candidate loading strategy set;

[0050] The second candidate loading strategy set with the shortest response time is used as the second loading strategy set.

[0051] In one or more embodiments, the user behavior data includes: client type, network type, resource type, resource size, and resource quantity.

[0052] In one or more embodiments, the loading strategy includes: whether to cache files, whether to compress images, whether to merge files, whether to lazily load, and resource loading priority.

[0053] In one or more embodiments, the type of neural network includes a back-propagation neural network.

[0054] Correspondingly, an embodiment of the present invention discloses an electronic device, including: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and when the computer program is executed by the processor, the various steps of the above-mentioned page loading method embodiment are implemented.

[0055] Accordingly, an embodiment of the present invention discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, each step of the above-mentioned page loading method embodiment is implemented.

[0056] The embodiments of the present invention include the following advantages:

[0057] The server obtains an access request for a target page initiated by a user on a client; the access request includes the user behavior data of the user; based on the initial neural network, a first loading strategy set corresponding to the user behavior data and used to load the target page is determined; the first loading strategy set includes a first loading strategy for various resources in the target page; the first loading strategy set is sent to the client, so that the client uses the first loading strategy set to load various resources in the target page. In this way, based on the behavior data of the user when accessing the website, the combination of loading strategies is dynamically adjusted using the trained neural network. Since the user's behavior data is different each time, the loading strategy can be dynamically adjusted according to different user behaviors, thereby providing an optimal performance optimization method adapted to different scenarios, so that users have the best experience when accessing the website.

[0058] Furthermore, different loading strategy combinations are configured for different user behavior data. In the case of poor network environment, key resources can be loaded first according to resource priority, and the loading of non-key resources can be reduced to speed up page loading. In the case of high device performance, more interactive effects and animations can be loaded to improve user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 It is a flow chart of the steps of a first embodiment of a page loading method of the present invention;

[0060] Figure 2 It is a schematic diagram of a scene mode of the present invention;

[0061] Figure 3 is a schematic diagram of the architecture of the neural network of the present invention;

[0062] Figure 4 This is a flow chart of the steps of a second embodiment of a page loading method of the present invention;

[0063] Figure 5 It is a structural block diagram of an embodiment of a page loading device of the present invention. DETAILED DESCRIPTION

[0064] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0065] One of the core concepts of the embodiments of the present invention is to use the behavioral data of users when visiting the website as the basis and to use the trained neural network to dynamically adjust the combination of loading strategies. Since the user's behavioral data is different each time, the loading strategy can be dynamically adjusted according to different user behaviors, thereby providing the best performance optimization method suitable for different scenarios, so that users have the best experience when visiting the website.

[0066] Furthermore, different loading strategy combinations are configured for different user behavior data. In the case of poor network environment, key resources can be loaded first according to resource priority, and the loading of non-key resources can be reduced to speed up page loading. In the case of high device performance, more interactive effects and animations can be loaded to improve user experience.

[0067] Reference Figure 1 , shows a flow chart of the steps of a page loading method embodiment 1 of the present invention, which is applicable to various types of websites, applications and platforms, especially when facing diverse user devices and network environments. Figure 2 , shows a schematic diagram of a scenario mode of an embodiment of the present invention, wherein the scenario may include three roles, namely, a user, a client (such as a Web application, also referred to as a "front end"), and a server (also referred to as a "back end"), which is a client-server model. The embodiment of the present invention can be applied to a server.

[0068] Users are the main body of using web applications. They access websites or applications through browsers and interact with backend services in the server. Users send requests to backend services by entering URLs, clicking links, filling out forms, etc., and receive responses from backend services to complete various operations and tasks.

[0069] The browser is a tool that users use to access web applications. It is responsible for parsing and rendering web page content, executing JavaScript code, managing page status and history, etc. The client sends requests to the backend service based on the user's operation, receives and processes the response returned by the backend service, and then displays the response content to the user.

[0070] The backend service is the core part of the Web application, responsible for processing user requests, executing business logic, accessing databases, generating responses, etc. The backend service receives requests from the browser, performs corresponding processing and calculations based on the request content, and then generates response data and returns it to the browser to complete the user's operations and needs.

[0071] The method may specifically include the following steps:

[0072] Step 101, obtaining an access request for a target page initiated by a user at a client; the access request includes user behavior data of the user.

[0073] Specifically, the user can initiate an access instruction in the client for the page that needs to be accessed (for easy distinction, recorded as the "target page"). After obtaining the access instruction, the client can obtain the user behavior data of the user, and generate an access request for the target page based on the user behavior data, and then send the access request to the server.

[0074] User behavior data may include: client type, network type, resource type, resource size, and resource quantity. Client type is used to distinguish clients with different cores. Usually, different client service providers provide different types of clients. Network types include but are not limited to WiFi, cellular network, Ethernet, 4G, and 3G. Resource types include but are not limited to HTML, CSS, JavaScript, images, videos, and fonts.

[0075] The client can obtain user behavior data through JavaScript code and the API (Application Programming Interface) provided by the browser. The JavaScript code can contain a built-in object navigator, use the navigator.userAgent property to obtain the type and version of the browser used by the user, and use the navigator.connection API to obtain network connection information, including the network type. In order to obtain data such as the resource type, resource size, and resource quantity involved in each user behavior, the client can add monitoring of resource information in the code, so that a piece of user behavior data can be collected for each interactive behavior of the user on the client.

[0076] It should be noted that, in addition to the above-mentioned method, user behavior data can also be obtained in other ways. In practical applications, the specific acquisition method can be set according to actual needs, and the embodiments of the present invention do not limit this.

[0077] Furthermore, the client can send the user behavior data to the server through an access request, or send it to the server independently through a data interface. In actual applications, the method for sending user behavior data can also be set according to actual needs, and the embodiments of the present invention do not limit this.

[0078] Step 102, determining a first loading strategy set corresponding to the user behavior data and used to load the target page based on the initial neural network; the first loading strategy set includes first loading strategies for various resources in the target page.

[0079] After obtaining the user behavior data, the server can input the user behavior data into the neural network (referred to as the "initial neural network"), thereby obtaining a loading strategy set corresponding to the user behavior data (referred to as the "first loading strategy set"). The first loading strategy set is used to load the target page visited by the user. Since the target page includes at least one type of resource, the first loading strategy set can include a loading strategy for each type of resource (referred to as the "first loading strategy").

[0080] Furthermore, the loading strategy may include: whether to cache files, whether to compress images, whether to merge files, whether to lazily load, and resource loading priority. For any resource, the data format of the corresponding loading strategy can be {whether to cache files: true / false, whether to compress images: true / false, whether to merge files: true / false, whether to lazily load: true / false, resource loading priority: k}, the first four parameters are of Boolean type, and the last one is of Number type. For example, for resource x, the corresponding loading strategy can be {x1: true, x2: true, x3: false, x4: false, x5: 1}, that is, the loading strategy of resource x is to use cached files and compressed images, and the resource loading priority is 1.

[0081] For another example, the target page includes three types of resources, x, y, and z. After the server obtains the user behavior data and inputs the user behavior data into the initial neural network, the loading strategy set output by the initial neural network is "{x1: true, x2: true, x3: false, x4: false, x5: 1}, {y1: false, y2: false, y3: true, y4: false, y5: 3}, {z1: true, z2: false, z3: false, z4: true, z5: 2}", that is, the loading strategy of the x resource is to use cache files and compressed images, the loading strategy of the y resource is to use merged files, and the loading strategy of the z resource is to use cache files and lazy loading. The loading order of resources is x resources (resource priority is 1), z resources (resource priority is 2), and y resources (resource priority is 3).

[0082] It should be noted that, in practical applications, the specific indicators included in the loading strategy and the data format of the loading strategy can be set according to actual needs, and the embodiment of the present invention does not limit this.

[0083] In an embodiment of the present invention, the initial neural network is generated in the following manner:

[0084] Acquire at least one historical user behavior data for the target page;

[0085] Determine the first candidate loading strategy set corresponding to each historical user behavior data, and obtain multiple pairs of historical user behavior data-first candidate loading strategy sets; wherein the response time corresponding to each first candidate loading strategy set meets the response time threshold;

[0086] Divide multiple pairs of historical user behavior data and first candidate loading strategy sets into training sets and test sets;

[0087] The historical user behavior data is used as input, the first candidate loading strategy set is used as output, and the training set and the test set are used to train a preset neural network to obtain a trained initial neural network.

[0088] Specifically, before training a neural network, relevant information of the neural network can be determined. Among them, the type of neural network may include a BP neural network (back propagation neural network), which is usually composed of an input layer, a hidden layer and an output layer, wherein the hidden layer may include one or more layers. The input neurons corresponding to the input layer may include five factors, namely: client type, network type, resource type, resource size and resource quantity. The neurons corresponding to the output layer may also include five factors, namely: whether to cache files, whether to compress pictures, whether to merge files, whether to lazy load and resource loading priority. To determine the number of neurons in the hidden layer, the following formula p = √(n+m)+a can be used, where n is the number of input neurons, m is the number of output neurons, and a is a constant ranging between [1,10].

[0089] Then, at least one historical user behavior data for the target page is obtained. Since the user behavior data includes 5 parameters, different parameter values ​​lead to different user behavior data. Therefore, the loading strategy set corresponding to each historical user behavior data can be determined (referred to as the "first candidate loading strategy set"), and each historical user behavior data is combined with its corresponding first candidate loading strategy set to obtain multiple pairs of historical user behavior data-first candidate loading strategy sets, and the multiple pairs of historical user behavior data-first candidate loading strategy sets are divided into training sets and test sets. The neural network is trained using the PyTorch deep learning framework and the training set, and the neural network is verified using the test set to obtain the trained initial neural network.

[0090] Reference Figure 3, shows the architecture of the neural network. Assuming that the target page includes x resources, y resources and z resources, the input data of the neural network can be {c1,c2,c3,c4,c5}, and the output data can be {x1,x2,x3,x4,x5}, {y1,y2,y3,y4,y5} and {z1,z2,z3,z4,z5}.

[0091] Furthermore, when training a neural network, a quantitative indicator for performance optimization, such as response time, can be set. At the same time, a response time threshold [b, d] can be set. In this way, whether the neural network meets the standard can be determined by detecting whether the response time falls within the response time threshold. Based on this, when determining the first candidate loading strategy set corresponding to each historical user behavior data, the response time corresponding to each first candidate loading strategy set falls within the response time threshold.

[0092] The response time can be generated by the client after the target page is loaded. The client can generate the response time through the performance.timing method or other methods. In actual applications, the specific method of generating the response time can be set according to actual needs, and the embodiment of the present invention does not limit this.

[0093] Step 103: Send the first loading strategy set to the client, so that the client uses the first loading strategy set to load various resources in the target page.

[0094] After determining the first loading strategy set, the server may send the first loading strategy set to the client. After acquiring the first loading strategy set, the client uses each first loading strategy in the first loading strategy set to load various resources to obtain a target page, and then displays the target page.

[0095] Furthermore, the client may add optional loading method codes in each resource location in the code, so that when the client executes the first loading strategy set, it can read the loading method code corresponding to the resource and then perform the corresponding loading operation according to the code.

[0096] Furthermore, a configuration file may be set in the client to record the historical loading strategy set for loading the target page. When the client sends an access request and obtains the first loading strategy set sent by the server, the first loading strategy set may be used to replace the historical loading strategy set, and the target page may be loaded using the first loading strategy set. In this way, the situation where the target page cannot be loaded without obtaining the first loading strategy set can be avoided.

[0097] In an embodiment of the present invention, the server obtains an access request for a target page initiated by a user at a client; the access request includes the user behavior data of the user; a first loading strategy set corresponding to the user behavior data and used to load the target page is determined based on an initial neural network; the first loading strategy set includes a first loading strategy for various resources in the target page; the first loading strategy set is sent to the client so that the client uses the first loading strategy set to load various resources in the target page. In this way, based on the behavior data of the user when accessing the website, the combination of loading strategies is dynamically adjusted using a trained neural network. Since the user's behavior data is different each time, the loading strategy can be dynamically adjusted according to different user behaviors, thereby providing an optimal performance optimization method adapted to different scenarios, so that users have the best experience when accessing the website.

[0098] Furthermore, different loading strategy combinations are configured for different user behavior data. In the case of poor network environment, key resources can be loaded first according to resource priority, and the loading of non-key resources can be reduced to speed up page loading. In the case of high device performance, more interactive effects and animations can be loaded to improve user experience.

[0099] Reference Figure 4 , shows a flow chart of the steps of a second embodiment of a page loading method of the present invention. The embodiment of the present invention can be applied to a server, and specifically may include the following steps:

[0100] Step 401: obtaining an access request for a target page initiated by a user at a client; the access request includes user behavior data of the user.

[0101] Specifically, the user can initiate an access instruction for the target page to be accessed in the client. After obtaining the access instruction, the client can obtain the user behavior data of the user, generate an access request for the target page based on the user behavior data, and then send the access request to the server.

[0102] Among them, user behavior data may include: client type, network type, resource type, resource size, and resource quantity. The client can obtain user behavior data through JavaScript code and the API provided by the browser. The JavaScript code can contain a built-in object navigator, use the navigator.userAgent property to obtain the browser type and version information used by the user, and use the navigator.connection API to obtain network connection information, including the network type. In order to obtain data such as resource type, resource size, and resource quantity involved in each user behavior, the client can add monitoring of resource information in the code, so that a piece of user behavior data can be collected for each interactive behavior of the user on the client.

[0103] It should be noted that, in addition to the above-mentioned method, user behavior data can also be obtained in other ways. In practical applications, the specific acquisition method can be set according to actual needs, and the embodiments of the present invention do not limit this.

[0104] Furthermore, the client can send the user behavior data to the server through an access request, or send it to the server independently through a data interface. In actual applications, the method for sending user behavior data can also be set according to actual needs, and the embodiments of the present invention do not limit this.

[0105] Step 402, determining a first loading strategy set corresponding to the user behavior data and used to load the target page based on the initial neural network; the first loading strategy set includes first loading strategies for various resources in the target page.

[0106] After acquiring the user behavior data, the server can input the user behavior data into the initial neural network to obtain a first loading strategy set corresponding to the user behavior data. The first loading strategy set is used to load the target page visited by the user. Since the target page includes at least one type of resource, the first loading strategy set can include the first loading strategy for each type of resource.

[0107] Furthermore, the loading strategy may include: whether to cache files, whether to compress images, whether to merge files, whether to lazily load, and resource loading priority. For any resource, the data format of the corresponding loading strategy can be {whether to cache files: true / false, whether to compress images: true / false, whether to merge files: true / false, whether to lazily load: true / false, resource loading priority: k}, the first four parameters are Boolean type, and the last one is Number type.

[0108] It should be noted that, in practical applications, the specific indicators included in the loading strategy and the data format of the loading strategy can be set according to actual needs, and the embodiment of the present invention does not limit this.

[0109] In an embodiment of the present invention, the initial neural network is generated in the following manner:

[0110] Acquire at least one historical user behavior data for the target page;

[0111] Determine the first candidate loading strategy set corresponding to each historical user behavior data, and obtain multiple pairs of historical user behavior data-first candidate loading strategy sets; wherein the response time corresponding to each first candidate loading strategy set meets the response time threshold;

[0112] Divide multiple pairs of historical user behavior data and first candidate loading strategy sets into training sets and test sets;

[0113] The historical user behavior data is used as input, the first candidate loading strategy set is used as output, and the training set and the test set are used to train a preset neural network to obtain a trained initial neural network.

[0114] Specifically, before training a neural network, relevant information of the neural network can be determined. Among them, the type of neural network can include a BP neural network, which is usually composed of an input layer, a hidden layer and an output layer, wherein the hidden layer can include one or more layers. The input neurons corresponding to the input layer can include 5 factors, namely: client type, network type, resource type, resource size and resource quantity. The neurons corresponding to the output layer can also include 5 factors, namely: whether to cache files, whether to compress pictures, whether to merge files, whether to lazy load and resource loading priority. To determine the number of neurons in the hidden layer, the following formula p = √(n+m)+a can be used, where n is the number of input neurons, m is the number of output neurons, and a is a constant ranging between [1,10].

[0115] Then, at least one historical user behavior data for the target page is obtained. Since the user behavior data includes 5 parameters, different parameter values ​​lead to different user behavior data. Therefore, the first candidate loading strategy set corresponding to each historical user behavior data can be determined, and each historical user behavior data is combined with its corresponding first candidate loading strategy set to obtain multiple pairs of historical user behavior data-first candidate loading strategy sets, and the multiple pairs of historical user behavior data-first candidate loading strategy sets are divided into training sets and test sets. The neural network is trained using the PyTorch deep learning framework and the training set, and the neural network is verified using the test set to obtain the trained initial neural network.

[0116] Assuming that the target page includes x resources, y resources and z resources, the input data of the neural network can be {c1, c2, c3, c4, c5}, and the output data can be {x1, x2, x3, x4, x5}, {y1, y2, y3, y4, y5} and {z1, z2, z3, z4, z5}.

[0117] Furthermore, when training a neural network, a quantitative indicator for performance optimization, such as response time, can be set. At the same time, a response time threshold [b, d] can be set. In this way, whether the neural network meets the standard can be determined by detecting whether the response time falls within the response time threshold. Based on this, when determining the first candidate loading strategy set corresponding to each historical user behavior data, the response time corresponding to each first candidate loading strategy set falls within the response time threshold.

[0118] The response time can be generated by the client after the target page is loaded. The client can generate the response time through the performance.timing method or other methods. In actual applications, the specific method of generating the response time can be set according to actual needs, and the embodiment of the present invention does not limit this.

[0119] Step 403: Send the first loading strategy set to the client, so that the client uses the first loading strategy set to load various resources in the target page.

[0120] After determining the first loading strategy set, the server may send the first loading strategy set to the client. After acquiring the first loading strategy set, the client uses each first loading strategy in the first loading strategy set to load various resources to obtain a target page, and then displays the target page.

[0121] Furthermore, the client may add optional loading method codes in each resource location in the code, so that when the client executes the first loading strategy set, it can read the loading method code corresponding to the resource and then perform the corresponding loading operation according to the code.

[0122] Furthermore, a configuration file may be set in the client to record the historical loading strategy set for loading the target page. When the client sends an access request and obtains the first loading strategy set sent by the server, the first loading strategy set may be used to replace the historical loading strategy set, and the target page may be loaded using the first loading strategy set. In this way, the situation where the target page cannot be loaded without obtaining the first loading strategy set can be avoided.

[0123] Step 404, when the response time is obtained, determine whether the response time meets the response time threshold; wherein the response time is generated by the client after the target page is loaded.

[0124] Specifically, after the client completes loading the target page using the first loading strategy set, it can generate the response time corresponding to the user's access request through the performance.timing method, and then send the response time to the server. When the server obtains the response time, it can detect whether the response time belongs to the preset response time threshold [b, d].

[0125] It should be noted that, in addition to being generated by the performance.timing method, the response time can also be generated by other methods. In practical applications, the specific method of generating the response time can be set according to actual needs, and the embodiment of the present invention does not limit this.

[0126] Step 405: If the response time does not meet the response time threshold, a second loading strategy set that meets the response time threshold is generated; the second loading strategy set includes second loading strategies for various resources in the target page.

[0127] If the response time does not meet the response time threshold, it means that the first loading strategy set is not the optimal strategy set. Therefore, a loading strategy set (referred to as the "second loading strategy") that meets the response time threshold and corresponds to the user behavior data can be generated.

[0128] In the embodiment of the present invention, generating a second loading strategy set that satisfies the response time threshold includes:

[0129] generating at least one second candidate loading strategy set corresponding to the user behavior data;

[0130] Determine the response time corresponding to each second candidate loading strategy set;

[0131] The second candidate loading strategy set with the shortest response time is used as the second loading strategy set.

[0132] Specifically, for the target page and user behavior data, at least one loading strategy set corresponding to the user behavior data (referred to as the "second candidate loading strategy set") can be generated, and then the response time corresponding to each second candidate loading strategy set can be generated through the performance.timing method, and the second candidate loading strategy set with the shortest response time can be used as the second loading strategy set corresponding to the user behavior data.

[0133] For example, assuming that the resources in the target page include images and JavaScript files, then you can generate loading strategy set 1: images {whether to cache files: true, whether to compress images: false, whether to merge files: true, whether to lazy load: false, resource loading priority: 1}, JavaScript files {whether to cache files: true, whether to compress images: false, whether to merge files: true, whether to lazy load: false, resource loading priority: 2}; loading strategy set 2: images {whether to cache files: false, whether to compress images: true, whether to merge files: true, whether to lazy load: false, resource loading priority: 1}, JavaScript files {whether to cache files: true, whether to compress images: true, whether to merge files: false, whether to lazy load: false, resource loading priority: 2}; loading strategy set 3: images {whether to cache files: false, whether to compress images: true, whether to merge files: true, whether to lazy load: false, resource loading priority: 2}, JavaScript files {whether to cache files: true, whether to compress images: true, whether to merge files: false, whether to lazy load: false, resource loading priority: 1}.

[0134] Then, the performance.timing method is used to generate the response times corresponding to the loading strategy sets 1, 2, and 3, which are 0.76ms, 1.03ms, and 0.92ms, respectively. Then, the loading strategy set 1 can be used as the second loading strategy set corresponding to the user behavior data.

[0135] Step 406: Use the user behavior data and the second loading strategy set to train the initial neural network to obtain a trained target neural network.

[0136] After obtaining the second loading strategy set, the user behavior data can be used as input, and the second loading strategy set can be used as output. The user behavior data and the second loading strategy set are used to train the initial neural network, thereby obtaining a trained neural network (referred to as the "target neural network"). In this way, for the next access request, the server can use the target neural network to determine the loading strategy set corresponding to the next user behavior data.

[0137] In an embodiment of the present invention, based on the behavioral data of users when visiting a website, a trained neural network is used to dynamically adjust the combination of loading strategies. Since the behavioral data of the user is different each time, the loading strategy can be dynamically adjusted according to different user behaviors, thereby providing an optimal performance optimization method adapted to different scenarios, so that users have the best experience when visiting the website.

[0138] Furthermore, different loading strategy combinations are configured for different user behavior data. In the case of poor network environment, key resources can be loaded first according to resource priority, and the loading of non-key resources can be reduced to speed up page loading. In the case of high device performance, more interactive effects and animations can be loaded to improve user experience.

[0139] Furthermore, the response time after the access request is used as the evaluation index of this loading strategy set, and the size of the index and the back propagation algorithm of the BP neural network are used to dynamically adjust the neural network parameters, so that the continuous optimization of the neural network can be achieved. As the number of users visiting the website increases and the user behavior and network environment change, the training data of the neural network will also increase, and the neural network can continue to learn and adapt to maintain the best optimization effect.

[0140] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0141] Reference Figure 5 , shows a structural block diagram of an embodiment of a page loading device of the present invention, which may specifically include the following modules:

[0142] The acquisition module 501 is used to acquire an access request for a target page initiated by a user at a client; the access request includes user behavior data of the user;

[0143] A first determination module 502 is used to determine, based on an initial neural network, a first loading strategy set corresponding to the user behavior data and used to load the target page; the first loading strategy set includes first loading strategies for various resources in the target page;

[0144] The sending module 503 is used to send the first loading strategy set to the client, so that the client adopts the first loading strategy set to load various resources in the target page.

[0145] In an embodiment of the present invention, it also includes:

[0146] A second determination module is used to determine whether the response time satisfies a response time threshold when the response time is acquired; wherein the response time is generated by the client after the target page is loaded;

[0147] A generating module, configured to generate a second loading strategy set satisfying the response time threshold if the response time does not satisfy the response time threshold; the second loading strategy set comprising second loading strategies for various resources in the target page;

[0148] A training module is used to train the initial neural network using the user behavior data and the second loading strategy set to obtain a trained target neural network.

[0149] In the embodiment of the present invention, the training module is further used for:

[0150] Acquire at least one historical user behavior data for the target page;

[0151] Determine the first candidate loading strategy set corresponding to each historical user behavior data, and obtain multiple pairs of historical user behavior data-first candidate loading strategy sets; wherein the response time corresponding to each first candidate loading strategy set meets the response time threshold;

[0152] Divide multiple pairs of historical user behavior data and first candidate loading strategy sets into training sets and test sets;

[0153] The historical user behavior data is used as input, the first candidate loading strategy set is used as output, and the training set and the test set are used to train a preset neural network to obtain a trained initial neural network.

[0154] In the embodiment of the present invention, the generating module is specifically used for:

[0155] generating at least one second candidate loading strategy set corresponding to the user behavior data;

[0156] Determine the response time corresponding to each second candidate loading strategy set;

[0157] The second candidate loading strategy set with the shortest response time is used as the second loading strategy set.

[0158] In an embodiment of the present invention, the user behavior data includes: client type, network type, resource type, resource size and resource quantity.

[0159] In the embodiment of the present invention, the loading strategy includes: whether to cache files, whether to compress pictures, whether to merge files, whether to lazily load, and resource loading priority.

[0160] In an embodiment of the present invention, the type of neural network includes a back propagation neural network.

[0161] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0162] An embodiment of the present invention further provides an electronic device, including:

[0163] It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned page loading method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0164] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned page loading method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0165] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0166] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0167] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0168] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0169] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0170] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0171] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0172] The page loading method and the page loading device provided by the present invention are introduced in detail above. The principle and implementation mode of the present invention are explained in this article by using specific examples. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation mode and the scope of application. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A page loading method, characterized in that: The method comprises: Obtaining an access request for a target page initiated by a user on a client; the access request includes user behavior data of the user; Determine, based on the initial neural network, a first loading strategy set corresponding to the user behavior data and used to load the target page; the first loading strategy set includes first loading strategies for various resources in the target page; The first loading strategy set is sent to the client, so that the client adopts the first loading strategy set to load various resources in the target page.

2. The page loading method according to claim 1, characterized in that: Also includes: When the response time is obtained, determining whether the response time meets the response time threshold; wherein the response time is generated by the client after the target page is loaded; If the response time does not meet the response time threshold, generating a second loading strategy set that meets the response time threshold; the second loading strategy set includes second loading strategies for various resources in the target page; The initial neural network is trained using the user behavior data and the second loading strategy set to obtain a trained target neural network.

3. The page loading method according to claim 1, characterized in that: The initial neural network is generated in the following way: Acquire at least one historical user behavior data for the target page; Determine the first candidate loading strategy set corresponding to each historical user behavior data, and obtain multiple pairs of historical user behavior data-first candidate loading strategy sets; wherein the response time corresponding to each first candidate loading strategy set meets the response time threshold; Divide multiple pairs of historical user behavior data and first candidate loading strategy sets into training sets and test sets; The historical user behavior data is used as input, the first candidate loading strategy set is used as output, and the training set and the test set are used to train a preset neural network to obtain a trained initial neural network.

4. The page loading method according to claim 2, characterized in that: The generating a second loading strategy set that satisfies the response time threshold comprises: generating at least one second candidate loading strategy set corresponding to the user behavior data; Determine the response time corresponding to each second candidate loading strategy set; The second candidate loading strategy set with the shortest response time is used as the second loading strategy set.

5. The page loading method according to claim 1, characterized in that: The user behavior data includes: client type, network type, resource type, resource size and resource quantity.

6. The page loading method according to any one of claims 1 to 4, characterized in that: The loading strategy includes: whether to cache files, whether to compress images, whether to merge files, whether to lazy load, and resource loading priority.

7. The page loading method according to any one of claims 1 to 3, characterized in that: Types of neural networks include back-propagation neural networks.

8. A page loading device, characterized in that: The device comprises: An acquisition module, used to acquire an access request for a target page initiated by a user at a client; the access request includes user behavior data of the user; A first determination module is used to determine, based on an initial neural network, a first loading strategy set corresponding to the user behavior data and used to load the target page; the first loading strategy set includes first loading strategies for various resources in the target page; The sending module is used to send the first loading strategy set to the client, so that the client adopts the first loading strategy set to load various resources in the target page.

9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the steps of the page loading method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the page loading method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Multi-modal map data service method and device, computer equipment and medium

    CN120541088A