Page loading method and device, equipment and storage medium
By determining and optimizing the loading order of resource files, the problem of low page loading efficiency in the existing technology is solved, and a faster and more efficient page loading experience is achieved.
Patent Information
- Application Number
- CN202411664605.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-04-15
AI Technical Summary
In the prior art, page loading efficiency is not high, affecting the user experience.
By obtaining the web page address entered by the user, determining the user's resource browsing request, obtaining the initial loading order and loading parameter values of the resource file to be loaded, determining the target loading order based on this information, and loading the resource file in the target loading order.
Improve the timeliness of page loading, prioritize the loading of key resources, enable users to see the core part of the page in the shortest time, improve the user's waiting experience, and enhance users' comfort and satisfaction when browsing the web page.
Smart Images

Figure CN119829850A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a page loading method, device, equipment and storage medium. Background Art
[0002] With the development of Web applications and changes in user needs, the ways in which servers display pages are becoming more and more diverse. In the prior art, when users request network resources, page loading efficiency is not high, which greatly affects the user experience. Summary of the invention
[0003] In view of the above problems, embodiments of the present invention are proposed to provide a page loading method, apparatus, device and storage medium that overcome the above problems or at least partially solve the above problems.
[0004] In order to solve the above problem, an embodiment of the present invention discloses a page loading method, which includes: Get the web page address that the user needs to access; Determining a user's resource browsing request according to the webpage address; the browsing request includes a storage location of a resource file to be accessed; Determining the resource files to be loaded according to the resource browsing request of the user; Obtaining the initial loading order of the resource files that need to be loaded; Determine the loading parameter value of the resource file that needs to be loaded; Determining a target loading order of the resource files to be loaded according to the initial loading order and the loading parameter values of the resource files to be loaded; According to the target loading order, the resource files that need to be loaded are loaded on the display page.
[0005] Optionally, it also includes: When loading a resource file to be loaded, obtaining the time when the user arrives at the page of the target resource file and the time when the user leaves the page of the target resource file; Determining the length of time the user stays on the page of the target resource file according to the time when the user arrives at the page of the target resource file and the time when the user leaves the page of the target resource file; Acquire the number of resource files on the page of the target resource file and the number of clicks on the target resource file by the user; Determining the number of clicks by the user on the page of the target resource file according to the number of the resource files and the number of clicks by the user on the target resource file; Obtain the actual height of the page of the target resource file and the height of the page scrolled by the user; Determining the speed at which the user scrolls the page according to the actual height of the page of the target resource file and the height of the page scrolled by the user; Determine user satisfaction based on the dwell time, the number of clicks, and the speed at which the user scrolls the page; When the user satisfaction reaches a preset user satisfaction, resource files of the same type as the target resource file are displayed to the user.
[0006] Optionally, determining a loading parameter value of the resource file to be loaded includes: Get the learning rate, discount factor, and exploration rate; Determine the loading parameter value of the resource file to be loaded according to the learning rate, the exploration factor and the exploration rate.
[0007] Optionally, loading the resource files to be loaded on the display page according to the target loading order includes: The resource files that need to be loaded are loaded in descending order according to the target loading order.
[0008] Optionally, it also includes: Determine the total number of resource files that need to be loaded; Obtaining the resource size and download time of the resource file of the display page; Determining an average download rate of the displayed page according to the resource size of the resource file of the displayed page and the download time; Determining the total loading time of the display page according to the total number of resource files that need to be loaded and the average download rate of the display page; Determine the type of resource file that needs to be loaded; The total loading time is reduced according to the type of resource files that need to be loaded.
[0009] Optionally, reducing the total loading time according to the type of the resource file to be loaded includes: When there are multiple resource files of the same type that need to be loaded, the resource files of the same type that need to be loaded in the display page are merged and displayed to reduce the total loading time.
[0010] Optionally, the resource file includes at least one of a hypertext markup language file, a cascading style sheet file, and a JavaScript file.
[0011] The present invention also discloses a page loading device, which is applied to a server, and the device comprises: A first acquisition module is used to acquire the webpage address that needs to be accessed, which is input by the user; A first determining module is used to determine a user's resource browsing request according to the webpage address; the browsing request includes a storage location of a resource file to be accessed; A second determination module, used to determine the resource file to be loaded according to the resource browsing request of the user; A second acquisition module is used to acquire the initial loading order of the resource files that need to be loaded; A third determining module, used to determine the loading parameter value of the resource file to be loaded; An order determination module, used to determine a target loading order of the resource files to be loaded according to the initial loading order and the loading parameter values of the resource files to be loaded; The loading module is used to load the resource files that need to be loaded on the display page according to the target loading order.
[0012] Optionally, it also includes: A third acquisition module is used to acquire the time when the user arrives at the page of the target resource file and the time when the user leaves the page of the target resource file when loading the resource file to be loaded; A fourth determination module, used to determine the length of time the user stays on the page of the target resource file according to the time when the user arrives at the page of the target resource file and the time when the user leaves the page of the target resource file; A fourth acquisition module, used to acquire the number of resource files on the page of the target resource file and the number of clicks on the target resource file by the user; A fifth determining module, configured to determine the number of clicks by the user on the page of the target resource file according to the number of the resource files and the number of clicks by the user on the target resource file; A fifth acquisition module, used to acquire the actual height of the page of the target resource file and the height of the page scrolled by the user; A speed determination module, used for determining the speed at which the user scrolls the page according to the actual height of the page of the target resource file and the height of the page scrolled by the user; A satisfaction determination module, used to determine user satisfaction according to the dwell time, the number of clicks, and the speed at which the user scrolls the page; A display module is used to display resource files of the same type as the target resource file to the user when the user satisfaction reaches a preset user satisfaction.
[0013] Optionally, the third determining module includes: Get submodules to get learning rate, discount factor and exploration rate; The loading parameter value determination submodule is used to determine the loading parameter value of the resource file to be loaded according to the learning rate, the exploration factor and the exploration rate.
[0014] Optionally, the loading module includes: The loading submodule is used to load the resource files that need to be loaded in the order from largest to smallest according to the target loading order.
[0015] Optionally, it also includes: A quantity determination module, used to determine the total quantity of resource files that need to be loaded; A sixth acquisition module, used to acquire the resource size and download time of the resource file of the display page; A download rate determination module, used to determine an average download rate of the displayed page according to the resource size of the resource file of the displayed page and the download time; A loading time determination module, used to determine the total loading time of the display page according to the total number of resource files that need to be loaded and the average download rate of the display page; A type determination module, used to determine the type of resource file to be loaded; The display module is used to reduce the total loading time according to the type of resource files that need to be loaded.
[0016] Optionally, the display module includes: The merging submodule is used to merge and display the resource files of the same type that need to be loaded in the display page when there are multiple resource files of the same type that need to be loaded, so as to reduce the total loading time.
[0017] Optionally, the resource file includes at least one of a hypertext markup language file, a cascading style sheet file, and a JavaScript file.
[0018] The present invention also discloses an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the above-mentioned page loading method when executed by the processor.
[0019] The present invention also discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the page loading method described above are implemented.
[0020] The embodiments of the present invention include the following advantages: The present invention can further determine the target loading order according to the loading parameter value and the initial loading order, and can reasonably arrange the loading order according to factors such as the importance and relevance of the resources and the criticality to the page display, and give priority to loading key resources, so that users can see the core part of the page in the shortest time, improve the user's waiting experience, and further improve the timeliness of the overall page loading; the present invention can accurately locate the resource files that need to be loaded, avoid unnecessary resource loading interference, and improve loading efficiency; the present invention can load resource files based on a reasonable target loading order, so that the page content can be gradually presented to the user in an orderly manner, enhancing the user's comfort and satisfaction when browsing the web. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 is a step flow chart of a page loading method provided by an embodiment of the present invention; Figure 2 It is a flow chart of a page loading method provided by an embodiment of the present invention; Figure 3 It is a structural block diagram of a page loading device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0022] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and understandable, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0023] One of the core concepts of the embodiments of the present invention is that the target loading order can be further determined according to the loading parameter value and the initial loading order, and the loading order can be reasonably arranged according to factors such as the importance and relevance of the resources and the criticality to the page display, and key resources can be loaded first, so that users can see the core part of the page in the shortest time, improve the user's waiting experience, and further improve the timeliness of the overall page loading; the present invention can accurately locate the resource files that need to be loaded, avoid unnecessary resource loading interference, and improve loading efficiency; the present invention can load resource files based on a reasonable target loading order, so that the page content can be presented to the user in an orderly and gradual manner, enhancing the user's comfort and satisfaction when browsing the web.
[0024] Reference Figure 1 , shows a flow chart of the steps of a page loading method provided by an embodiment of the present invention, which is applied to a server. The method may include the following steps: Step 101, obtaining the webpage address to be accessed input by the user.
[0025] In an embodiment of the present invention, a corresponding input interface is provided on the server side for the user to input the address of the web page that the user wishes to access (also commonly referred to as URL, Uniform Resource Locator). The user enters the address information of the target web page in the correct format through an input box such as the address bar of a browser. After the server obtains the address entered by the user, it knows the user's access intention and then starts the corresponding resource loading process.
[0026] Step 102: determining the user's resource browsing request according to the webpage address; the browsing request includes the storage location of the resource file to be accessed.
[0027] In the embodiment of the present invention, after receiving the webpage address input by the user, the server will parse the address.
[0028] First, based on the domain name information in the address, find the corresponding server storage system or establish a connection with the relevant back-end service to obtain resource information related to the web page. Then, based on the path part in the address and possible query parameters, determine the specific storage location of various resource files involved in the web page (such as the HTML file itself, the associated CSS style files, JavaScript script files, image files, video files, etc.) in the server storage system.
[0029] In one example, if a web page address points to a news page containing multimedia presentations, the server can parse the address to find out in which folder the corresponding HTML file is stored on the server, as well as in which corresponding subfolders or storage areas the images, videos and other resource files embedded in the page are stored. By integrating the storage locations of these resource files, it constitutes the user's resource browsing request content, which clarifies which resources need to be obtained from which places to fully present the web page the user wants to visit.
[0030] Step 103: Determine the resource files to be loaded according to the user's resource browsing request.
[0031] In an embodiment of the present invention, the server can further go to the corresponding storage location to retrieve relevant resource files based on the resource file storage location contained in the resource browsing request specified in the previous step. The server will check the specific files in each location that meet the requirements of web page construction and display, and eliminate those files that may have expired, damaged, or do not match the current web page version, and filter out the valid resource files that are indeed used to build the web page that the current user requests to access. In one example, some cached old versions of CSS style files may no longer be applicable due to web page updates, so the server will not include them in the scope of what needs to be loaded; and for the dynamic interactive script files newly added to the web page, as long as they are found in the storage location corresponding to the resource browsing request and are valid, they will be determined as one of the resource files that need to be loaded. Through such a screening mechanism, the collection of all resource files that are truly needed for this page load can be accurately determined.
[0032] Step 104, obtaining the initial loading order of the resource files to be loaded.
[0033] In the embodiment of the present invention, the server determines the initial loading order of resource files according to certain preset rules or default policies.
[0034] A common way is to sort resource files according to their importance and urgency to page presentation. For example, load the HTML file first, because it builds the basic skeleton structure of the web page, then load the key CSS style file to give the page a preliminary visual presentation, and then load the images, texts and other resource files necessary for the first-screen display, so that users can see the main content of the page as soon as possible; subsequently load the JavaScript script files used to implement interactive functions and other resources that are not on the first screen but are also part of the page (such as some friendly link-related files and secondary images at the bottom of the page).
[0035] In addition, it may also be sorted according to file type, such as loading text files first, and then loading multimedia files such as pictures and videos. This initial loading order is the basis for further optimization and adjustment. It can be a fixed order built into the server, or it may be dynamically generated based on factors such as the characteristics of the web page and past loading experience.
[0036] Step 105: Determine the loading parameter value of the resource file to be loaded.
[0037] In the embodiment of the present invention, the loading parameter value of the resource file is used to characterize the parameter value of the resource file that plays a key role in the page function and appearance, and can be determined according to the file size, file type, and average duration of past loading.
[0038] The loading parameter values of resource files can also be determined in combination with other parameters, such as the current server load (if the server load is light, the parameter values of each resource file can be appropriately increased to speed up the overall loading speed; if the load is heavy, the parameter values of non-critical files can be lowered). The corresponding loading parameter values can be calculated for each resource file that needs to be loaded through specific algorithms or rules (such as weighted calculations, experience-based scoring rules, etc.).
[0039] Step 106: Determine the target loading order of the resource files to be loaded according to the initial loading order and the loading parameter values of the resource files to be loaded.
[0040] In the embodiment of the present invention, based on the initial loading order obtained previously and the determined loading parameter values of each resource file, the server will adjust and optimize the initial loading order to determine the final target loading order.
[0041] Generally speaking, resource files with higher loading parameter values will be loaded in advance, that is, they will be placed forward in the order, so that they can be loaded into the client browser faster for page construction. In one example, if an image file is originally at the end of the initial loading order, but its loading parameter value is calculated to find that it is of high importance to the current page display (it may be a key display element on the first screen, etc.), and the server and user network conditions allow it to be loaded quickly, then this image file will be adjusted forward in the order and loaded before some files with lower parameter values. In this way, all resource files are re-arranged in order according to their parameter values to form a more reasonable target loading order that can better meet the needs of fast and efficient page presentation.
[0042] Step 107: Load the resource files that need to be loaded on the display page according to the target loading order.
[0043] In an embodiment of the present invention, after the target loading order is determined, the server can send each resource file to the client browser for loading in this order. For each resource file, the server will use a suitable transmission protocol and encoding method for data transmission according to its file type and the support of the client browser. For example, for HTML files, they are transmitted in text format and sent to the browser following the HTTP or HTTPS protocol; image files are encoded accordingly according to their format (such as JPEG, PNG, etc.) and then transmitted.
[0044] On the client browser side, after receiving the resource file, it will be parsed and rendered according to the corresponding rules. For example, the browser's HTML parser parses the HTML file to build a DOM tree, the CSS parser processes the CSS style file and applies it to the DOM element, and the JavaScript engine executes the script file to implement interactive functions. By loading and processing each resource file in turn, the web page content requested by the user is gradually presented on the display page.
[0045] The present invention discloses a page loading method, which can further determine the target loading sequence according to the loading parameter value and the initial loading sequence, and can reasonably arrange the loading sequence according to factors such as the importance and relevance of resources and the criticality to page display, and load key resources first, so that users can see the core part of the page in the shortest time, improve the user's waiting experience, and further improve the timeliness of the overall page loading; the present invention can accurately locate the resource files that need to be loaded, avoid the loading interference of unnecessary resources, and improve the loading efficiency; the present invention can load resource files based on a reasonable target loading sequence, so that the page content can be gradually presented to the user in an orderly manner, and enhance the user's comfort and satisfaction when browsing the web page.
[0046] In one embodiment of the present invention, it also includes: when loading the resource file that needs to be loaded, obtaining the time when the user arrives at the page of the target resource file and the time when the user leaves the page of the target resource file; determining the user's stay time on the page of the target resource file according to the time when the user arrives at the page of the target resource file and the time when the user leaves the page of the target resource file; obtaining the number of resource files on the page of the target resource file and the number of clicks of the user on the target resource file; determining the number of clicks of the user on the page of the target resource file according to the number of resource files and the number of clicks of the user on the target resource file; obtaining the actual height of the page of the target resource file and the height of the page scrolled by the user; determining the speed at which the user scrolls the page according to the actual height of the page of the target resource file and the height of the page scrolled by the user; determining the user's satisfaction according to the stay time, the number of clicks, and the speed at which the user scrolls the page; when the user satisfaction reaches the preset user satisfaction, displaying the resource files of the same type as the target resource files to the user.
[0047] In the embodiment of the present invention, when loading a resource file that needs to be loaded, the time when the user arrives at the page of the target resource file and the time when the user leaves the page of the target resource file can be obtained, and the length of time the user stays on the page of the target resource file is determined according to the time when the user arrives at the page of the target resource file and the time when the user leaves the page of the target resource file, as shown in formula (1): Formula (1) in Indicates the time when the page leaving the target resource file is opened. It indicates the time when the user reaches the page of the target resource file, and t indicates the length of time the user stays on the page of the target resource file.
[0048] Furthermore, the number of resource files on the page of the target resource file and the number of clicks on the target resource file by the user can be obtained; according to the number of resource files and the number of clicks on the target resource file by the user, the number of clicks on the page of the target resource file by the user is determined, as shown in formula (2): Formula (2) in, Indicates the number of resource files, i indicates the resource file, represents the number of times users click on the target resource file, and c represents the number of times users click on the page of the target resource file.
[0049] Furthermore, the actual height of the page of the target resource file and the height of the page scrolled by the user can be obtained, and the speed of the user scrolling the page can be determined according to the actual height of the page of the target resource file and the height of the page scrolled by the user, as shown in formula (3): Formula (3) in, Refers to the height of the page that the user scrolls. refers to the actual height of the page of the target resource file, and d refers to the speed at which the user scrolls the page.
[0050] Finally, after the calculation, the user satisfaction can be calculated, as shown in formula (4): Formula (4) Among them, A refers to user satisfaction, The coefficient representing the length of stay, refers to the coefficient of the number of clicks, Refers to the coefficient of rolling depth. , , Both are set to 1.
[0051] The server pre-sets a threshold value representing user satisfaction (such as the value of 0.6 mentioned above). When the user satisfaction value calculated by the previous steps reaches or exceeds this preset threshold, the server will filter out other resource files of the same type from the database or related resource library according to the type information of the target resource file (such as news articles, product details, picture collections, etc.), and then display these similar resource files to the user in an appropriate manner (such as dynamically adding recommended links on the page, displaying related recommended content at the bottom of the current page, recommending when the user leaves the current page and jumps to a new page, etc.), in the hope that the user will continue to browse the content of interest, increase the user's stay time and browsing depth on the website, and improve the user experience and the website's business indicators; the present invention can more comprehensively collect relevant data on the interaction between users and page resource files, and evaluate user satisfaction based on this, and then make corresponding content recommendations based on the satisfaction level, thereby optimizing the user's browsing experience and the website's operating results.
[0052] In one embodiment of the present invention, determining the loading parameter values of the resource files to be loaded includes: obtaining a learning rate, a discount factor, and an exploration rate; and determining the loading parameter values of the resource files to be loaded based on the learning rate, the exploration factor, and the exploration rate.
[0053] In the embodiment of the present invention, the learning rate is mainly used to control the speed or amplitude of adjusting the resource file loading parameter value based on past experience or feedback in the resource loading scenario. It is somewhat similar to the concept of adjusting the step size. If the learning rate is set to a large value, the loading parameter value will be adjusted to a large extent according to the feedback each time; on the contrary, if the learning rate is small, the adjustment amplitude will be relatively subtle, and the system will respond to the feedback slowly. The learning rate is usually a value between 0 and 1. For example, at a learning rate of 0.1, when a loading feedback is received indicating that a resource file has a good loading effect, the loading parameter value will be correspondingly increased by a relatively moderate amplitude according to certain rules, so that the resource file will be more inclined to be loaded first in the future.
[0054] The discount factor is often used to consider the impact of future benefits (in the case of resource loading, it can be compared to the benefits or value that may be brought by loading the resource file in the future) on the current decision. It reflects how the importance of future feedback information changes relative to the current one as time goes by or the number of loads increases. For example, a discount factor of 0.9 means that the impact of a future load feedback will be converted into the current load parameter value adjustment decision at a ratio of 0.9, and the influence of future feedback will gradually decrease according to this discount ratio. It also generally ranges from 0 to 1. The closer it is to 1, the more the system values long-term impact; the closer it is to 0, the more emphasis is placed on current immediate feedback.
[0055] The exploration rate specifies the probability of exploration behavior, that is, how likely it is to try to load resource files that are rarely selected or whose loading effects are not fully understood. During the resource loading process, if you always load resources according to existing experience and fixed patterns, you may miss a better resource combination or loading order. The existence of the exploration rate is to encourage breaking the routine to a certain extent and to explore potential better loading methods. For example, the exploration rate is set to 0.2, which means that each time a resource loading decision is made, there is a 20% probability that it will not be based on conventional judgments such as the current existing loading parameter values, but will randomly select some relatively unfamiliar resource files to load, in order to explore whether they can bring better overall loading effects.
[0056] The present invention can use factors such as learning rate, exploration factor and exploration rate to determine the loading parameter value of resource files, which can make the resource loading process more intelligent and dynamic, and better meet the requirements of system operation, user experience and other aspects.
[0057] In an embodiment of the present invention, resource files to be loaded are loaded on a display page according to a target loading sequence, including: loading resource files to be loaded in a descending order of the target loading sequence.
[0058] In an embodiment of the present invention, the server first identifies the resource file with the largest value (that is, the one that is ranked first and has the highest priority) in the target loading sequence. For example, in a web page loading scenario, the server determines that the HTML file has the largest sequence value in the current target loading sequence, and it constructs the framework structure of the entire web page. Then the server will first send this HTML file to the client browser. After the browser receives the HTML file, it will start the corresponding parsing process. Its HTML parser starts to parse the file and constructs a document object model (DOM) tree. At this time, although the page does not have a style and complete content presentation, it already has a basic structural framework. The user can see that the page begins to have a preliminary outline, such as the appearance of basic elements such as the page title bar and the navigation bar placeholder, so that the user knows that the page is loading and has a certain response.
[0059] Step 2: Further, the server searches for the next resource file with a slightly smaller sequence value but is still relatively important in order to load it. This may usually be a critical CSS style file. After the server sends the CSS file to the browser, the browser's CSS parser will process it and apply the corresponding style to the corresponding elements on the previously constructed DOM tree according to the style rules, so that the page begins to have a visual presentation. For example, the text has fonts and colors, and the various parts of the page have layout and typesetting. The appearance of the page gradually becomes clear and beautiful, and users can see that the page is being improved little by little and is no longer just a blank frame structure.
[0060] Step 3: After that, the resource files with lower order values are loaded in sequence, such as pictures, texts and other content resources required for the first screen display. The server sends these resource files one by one. After receiving the image file, the browser will decode it and display it in the corresponding position, and the text content will be filled in the corresponding text element area, so that the main content of the page is gradually enriched. Users can see the complete first screen information, obtain key page content and perform some basic interactive operations.
[0061] Continuous loading until completion: As the loading process continues, subsequent resource files with lower sequence values, such as JavaScript script files used to implement complex interactive functions, some auxiliary images or link resources displayed outside the first screen, etc., will also be loaded into the browser in order from large to small. JavaScript script files are executed by the browser's JavaScript engine to implement interactive functions such as menu expansion and collapse, form validation, and dynamic data update, making the page more vivid and easy to use; and the loading of other auxiliary resources further improves the overall display of the page, such as the pictures and texts related to the friendly links at the bottom of the page will gradually appear, and finally complete the loading of all resource files of the entire web page, presenting a complete page with full functions and rich content for users to browse and use.
[0062] The present invention loads resource files in a target loading order from large to small, so that users can quickly see the process of a page gradually changing from a blank state to a complete page with a basic structure and style presentation, and then to a complete page with rich content and interactive functions, thus avoiding the bad experience of users waiting for a blank page for a long time. In particular, the key resources related to the first screen are loaded first, so that users can obtain the core content they want to see most in the shortest time. For example, when visiting a news information web page, they can quickly see the news title, main pictures and the beginning text content, which improves the user's patience in waiting and satisfaction with the web page. Moreover, even if some resources are loaded later, it will not affect the user's browsing and operation of the page part that has been presented, so that the user can always interact with the page to a certain extent during the entire page loading process, which enhances the usability and fluency of the web page.
[0063] In one embodiment of the present invention, it also includes: determining the total number of resource files that need to be loaded; obtaining the resource size and download time of the resource files of the display page; determining the average download rate of the display page based on the resource size and download time of the resource files of the display page; determining the total loading time of the display page based on the total number of resource files that need to be loaded and the average download rate of the display page; determining the type of resource files that need to be loaded; and reducing the total loading time based on the type of resource files that need to be loaded.
[0064] In the embodiment of the present invention, after receiving a user's access request for a specific web page, the server will sort out all the resource files that need to be loaded this time according to the composition rules of the web page and the relevant information of the user request. In this process, the server can count the number of resource files. For example, when parsing the content pointed to by the web page address, the server will search for the HTML file associated with it and the CSS style file referenced in the HTML file (through <link> Tags, etc.), JavaScript script files (via <script>标签引入)以及图片、视频等各类媒体文件,每找到一个符合要求的资源文件,就在计数器上加1,最终计数器的数值就是需要加载的资源文件的总数量。
[0065] 对于每个已经获取到资源大小和下载时间的资源文件,先根据公式:下载速率=资源大小÷下载时间来计算平均下载速率,在计算出平均下载速率后,可以根据平均下载速率计算每个资源文件的加载时间,再根据需要加载的资源文件的总数量和每个资源文件的加载时间计算出显示页面的总加载时间。
[0066] 服务器端和客户端浏览器都可以通过查看资源文件的扩展名来初步判断文件类型,比如,扩展名是".html”的文件通常为HTML文件,用于构建网页的基本框架;".css”的为CSS样式文件,负责网页的样式设定;".js”的就是JavaScript脚本文件,实现网页的交互功能等。
[0067] 在确定资源文件的类型后,可以根据资源文件的类型对总加载时间进行调整,例如当资源文件为图片文件,在保证图片质量满足页面展示需求的前提下,对图片进行压缩处理,减小文件大小,例如,使用图像编辑工具或者在线的图片压缩服务,将原本500KB的高清产品图片压缩到200KB左右,既不影响用户对图片内容的查看,又能大幅减少图片下载时间,降低总加载时间。
[0068] 在另一种示例中,当资源文件类型为HTML文件,可以通过精简HTML代码,去除不必要的标签嵌套、空格和注释等冗余内容,减小文件大小,从而加快下载速度。
[0069] 在本发明的一种实施例方式中,根据需要加载的资源文件的类型,降低总加载时间,包括:当存在多个相同类型的需要加载的资源文件时,将显示页面中相同类型的需要加载的资源文件进行合并显示,以降低总加载时间。
[0070] 本发明实施例中,当资源文件类型为HTML文件,在一些复杂的网页中,可能存在多个通过不同方式引入的HTML片段,比如有的是通过服务器端动态生成并嵌入到主页面的局部HTML模块,还有的是通过JavaScript动态加载并插入到页面特定位置的HTML片段,对于这类情况,可以在服务器端或者客户端将这些分散的HTML片段按照页面布局和功能需求进行整合,合并成一个完整的、连续的HTML文件进行加载。
[0071] 在一种示例中,原本在页面加载过程中,需要先后向服务器发起3次请求分别获取商品评价模块、推荐商品模块以及页面底部的友情链接模块对应的HTML片段,现在通过服务器端脚本提前将这3个模块的HTML内容合并到主HTML文件中相应位置,浏览器只需一次请求就可以获取完整包含这些内容的HTML文件;显著减少了浏览器向服务器发起请求的次数,避免了多次请求带来的网络连接建立、等待响应等时间损耗,而且将HTML内容合并后,浏览器在解析构建页面DOM树(文档对象模型树)时,能够更连贯、高效地进行处理,无需频繁切换不同来源的HTML片段进行解析,加快了页面基本结构的构建速度,使得用户能够更快看到页面的完整框架,进而降低了总加载时间。
[0072] 在本发明的一种实施例方式中,资源文件包括超文本标记语言文件、层叠样式表文件、JavaScript文件中的至少一种。
[0073] 本发明实施例中,资源文件可以包括多种类型的资源,如:1)HTML文件:作为网页基本结构,包括文档的内容和结构信息;2)CSS、JavaScript文件:CSS定义样式,控制页面的布局、颜色、字体等外观效果;JavaScript用于网页的交互和动态效果,包括事件处理、DOM操作、数据请求等功能;3)图像文件:图像文件包括JPG、PNG、GIF等格式的图片文件,用于网页的装饰、展示等;4)音频文件:音频文件包括MP3、WAV、OGG等格式的音频文件,用于页面音频的播放;5)视频文件:视频文件包括MP4、WebM、AVI等格式的视频文件,用于页面的视频播放;6)媒体文件:媒体文件包括动画、SVG等格式的文件,用于网页的特效和动画展示。
[0074] 具体包括哪些可以根据用户的需求进行设定,在此不做限定。
[0075] 如图2,示出了本发明实施例提供的一种页面加载方法的流程示意图,用户在浏览器的地址栏中输入想要访问的网页的URL,浏览器根据URL内容生成HTTP请求,包含请求文件的位置、方式等,并通过已经建立的TCP连接发送给服务器,服务器接收到请求后,会根据HTTP请求的内容获取相应的HTML文件,并可能包含图片、CSS、JavaScript等其他资源文件,服务器将获取到的这些文件发送给浏览器,浏览器接收到服务器发送的文件后,会开始解析HTML文件并生成DOM树,同时解析CSS并生成CSS规则。然后,浏览器会将DOM树和CSS规则合并生成渲染树,最后根据渲染树进行页面的渲染和显示。
[0076] 本发明公开了一种页面加载方法,可以根据加载参数值和初始加载顺序来进一步确定目标加载顺序,可以按照资源的重要性、相关性以及对页面展示的关键程度等因素合理安排加载先后次序,优先加载关键资源,让用户在最短时间内看到页面的核心部分,改善用户等待体验,进一步提高页面整体加载的时效性;本发明可以精准定位需要加载的资源文件,避免了不必要资源的加载干扰,提升加载效率;本发明可以基于合理的目标加载顺序加载资源文件,使得页面内容能够有条不紊地逐步呈现给用户,增强用户浏览网页时的舒适度和满意度。
[0077] 需要说明的是,对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明实施例并不受所描述的动作顺序的限制,因为依据本发明实施例,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作并不一定是本发明实施例所必须的。
[0078] 参照图3,示出了本发明实施例提供的一种页面加载装置,应用于服务器,所述装置包括:第一获取模块201,用于获取用户输入的需要访问的网页地址;第一确定模块202,用于根据所述网页地址,确定用户的资源浏览请求;所述浏览请求包括需要访问的资源文件的存储位置;第二确定模块203,用于根据所述用户的资源浏览请求,确定需要加载的资源文件;第二获取模块204,用于获取所述需要加载的资源文件初始加载顺序;第三确定模块205,用于确定所述需要加载的资源文件的加载参数值;顺序确定模块206,用于根据所述初始加载顺序和所述需要加载的资源文件的加载参数值,确定所述需要加载的资源文件的目标加载顺序;加载模块207,与根据所述目标加载顺序,在显示页面对所述需要加载的资源文件进行加载。
[0079] 本发明公开了一种页面加载装置,可以根据加载参数值和初始加载顺序来进一步确定目标加载顺序,可以按照资源的重要性、相关性以及对页面展示的关键程度等因素合理安排加载先后次序,优先加载关键资源,让用户在最短时间内看到页面的核心部分,改善用户等待体验,进一步提高页面整体加载的时效性;本发明可以精准定位需要加载的资源文件,避免了不必要资源的加载干扰,提升加载效率;本发明可以基于合理的目标加载顺序加载资源文件,使得页面内容能够有条不紊地逐步呈现给用户,增强用户浏览网页时的舒适度和满意度。
[0080] 在本发明的一种实施例方式中,还包括:第三获取模块,用于在对需要加载的资源文件进行加载时,获取用户到达所述目标资源文件的页面的时间和离开所述目标资源文件的页面的时间;第四确定模块,用于根据所述用户到达所述目标资源文件的页面的时间和离开所述目标资源文件的页面的时间,确定所述用户在所述目标资源文件的页面的停留时长;第四获取模块,用于获取所述目标资源文件的页面的资源文件的数量和所述用户对所述目标资源文件的点击次数;第五确定模块,用于根据所述资源文件的数量和所述用户对所述目标资源文件的点击次数,确定用户在所述目标资源文件的页面的点击次数;第五获取模块,用于获取所述目标资源文件的页面的实际高度和用户滚动的页面高度;速度确定模块,用于根据所述目标资源文件的页面的实际高度和用户滚动的页面高度,确定所述用户滚动页面的速度;满意度确定模块,用于根据所述停留时长、所述点击次数、所述用户滚动页面的速度,确定用户满意度;展示模块,用于当所述用户满意度达到预设用户满意度时,向所述用户展示与所述目标资源文件相同类型的资源文件。
[0081] 在本发明的一种实施例方式中,所述第三确定模块,包括:获取子模块,用于获取学习率、折扣因子和探索率;加载参数值确定子模块,用于根据所述学习率、所述探索因子和所述探索率,确定所述需要加载的资源文件的加载参数值。
[0082] 在本发明的一种实施例方式中,所述加载模块,包括:加载子模块,用于按照所述目标加载顺序从大到小的顺序,对所述需要加载的资源文件进行加载。
[0083] 在本发明的一种实施例方式中,还包括:数量确定模块,用于确定所述需要加载的资源文件的总数量;第六获取模块,用于获取所述显示页面的资源文件的资源大小和下载时间;下载速率确定模块,用于根据所述显示页面的资源文件的资源大小和所述下载时间,确定所述显示页面的平均下载速率;加载时间确定模块,用于根据所述需要加载的资源文件的总数量、所述显示页面的平均下载速率,确定所述显示页面的总加载时间;类型确定模块,用于确定所述需要加载的资源文件的类型;显示模块,用于根据所述需要加载的资源文件的类型,在所述显示页面对所述需要加载的资源文件进行显示。
[0084] 在本发明的一种实施例方式中,所述显示模块,包括:合并子模块,用于当存在多个相同类型的需要加载的资源文件时,将所述显示页面中所述相同类型的需要加载的资源文件进行合并显示。
[0085] 在本发明的一种实施例方式中,所述资源文件包括超文本标记语言文件、层叠样式表文件、JavaScript文件中的至少一种。
[0086] 本发明公开了一种页面加载装置,可以根据加载参数值和初始加载顺序来进一步确定目标加载顺序,可以按照资源的重要性、相关性以及对页面展示的关键程度等因素合理安排加载先后次序,优先加载关键资源,让用户在最短时间内看到页面的核心部分,改善用户等待体验,进一步提高页面整体加载的时效性;本发明可以精准定位需要加载的资源文件,避免了不必要资源的加载干扰,提升加载效率;本发明可以基于合理的目标加载顺序加载资源文件,使得页面内容能够有条不紊地逐步呈现给用户,增强用户浏览网页时的舒适度和满意度。
[0087] 对于装置实施例而言,由于其与方法实施例基本相似,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。
[0088] 本发明实施例还提供了一种电子设备,包括:包括处理器、存储器及存储在存储器上并能够在处理器上运行的计算机程序,该计算机程序被处理器执行时实现上述页面加载方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。
[0089] 本发明实施例还提供了一种计算机可读存储介质,计算机可读存储介质上存储计算机程序,计算机程序被处理器执行时实现上述页面加载方法实施例的各个过程,且能达到相同的技术效果,为避免重复,这里不再赘述。
[0090] 本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。
[0091] 本领域内的技术人员应明白,本发明实施例的实施例可提供为方法、装置、或计算机程序产品。因此,本发明实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
[0092] 本发明实施例是参照根据本发明实施例的方法、终端设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理终端设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理终端设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
[0093] 这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理终端设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
[0094] 这些计算机程序指令也可装载到计算机或其他可编程数据处理终端设备上,使得在计算机或其他可编程终端设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程终端设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
[0095] 尽管已描述了本发明实施例的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明实施例范围的所有变更和修改。
[0096] 最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语"包括”"包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端设备所固有的要素。在没有更多限制的情况下,由语句"包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端设备中还存在另外的相同要素。
[0097] 以上对本发明所提供的一种页面加载方法、装置、设备和存储介质,进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。< / script>
Claims
1. A page loading method, characterized in that: Applied to a server, the method comprises: Get the web page address that the user needs to access; Determining a user's resource browsing request according to the webpage address; the browsing request includes a storage location of a resource file to be accessed; Determining the resource files to be loaded according to the resource browsing request of the user; Obtaining the initial loading order of the resource files that need to be loaded; Determine the loading parameter value of the resource file that needs to be loaded; Determining a target loading order of the resource files to be loaded according to the initial loading order and the loading parameter values of the resource files to be loaded; According to the target loading order, the resource files that need to be loaded are loaded on the display page.
2. The method according to claim 1, characterized in that Also includes: When loading a resource file to be loaded, obtaining the time when the user arrives at the page of the target resource file and the time when the user leaves the page of the target resource file; Determining the length of time the user stays on the page of the target resource file according to the time when the user arrives at the page of the target resource file and the time when the user leaves the page of the target resource file; Acquire the number of resource files on the page of the target resource file and the number of clicks on the target resource file by the user; Determining the number of clicks by the user on the page of the target resource file according to the number of the resource files and the number of clicks by the user on the target resource file; Obtain the actual height of the page of the target resource file and the height of the page scrolled by the user; Determining the speed at which the user scrolls the page according to the actual height of the page of the target resource file and the height of the page scrolled by the user; Determine user satisfaction based on the dwell time, the number of clicks, and the speed at which the user scrolls the page; When the user satisfaction reaches a preset user satisfaction, resource files of the same type as the target resource file are displayed to the user.
3. The method according to claim 1, characterized in that The step of determining the loading parameter value of the resource file to be loaded includes: Get the learning rate, discount factor, and exploration rate; Determine the loading parameter value of the resource file to be loaded according to the learning rate, the exploration factor and the exploration rate.
4. The method according to claim 1, characterized in that: The loading of the resource files to be loaded on the display page according to the target loading order includes: The resource files that need to be loaded are loaded in descending order according to the target loading order.
5. The method according to claim 1, characterized in that Also includes: Determine the total number of resource files that need to be loaded; Obtaining the resource size and download time of the resource file of the display page; Determining an average download rate of the displayed page according to the resource size of the resource file of the displayed page and the download time; Determining the total loading time of the display page according to the total number of resource files that need to be loaded and the average download rate of the display page; Determine the type of resource file that needs to be loaded; The total loading time is reduced according to the type of resource files that need to be loaded.
6. The method according to claim 5, characterized in that The reducing the total loading time according to the type of the resource file to be loaded includes: When there are multiple resource files of the same type that need to be loaded, the resource files of the same type that need to be loaded in the display page are merged and displayed to reduce the total loading time.
7. The method according to claim 1, characterized in that The resource file includes at least one of a hypertext markup language file, a cascading style sheet file, and a JavaScript file.
8. A page loading device, characterized in that: Applied to a server, the device comprises: A first acquisition module is used to acquire the webpage address that needs to be accessed, which is input by the user; A first determining module is used to determine a user's resource browsing request according to the webpage address; the browsing request includes a storage location of a resource file to be accessed; A second determination module, used to determine the resource file to be loaded according to the resource browsing request of the user; A second acquisition module is used to acquire the initial loading order of the resource files that need to be loaded; A third determining module, used to determine the loading parameter value of the resource file to be loaded; An order determination module, used to determine a target loading order of the resource files to be loaded according to the initial loading order and the loading parameter values of the resource files to be loaded; The loading module is used to load the resource files that need to be loaded on the display page according to the target loading order.
9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor is used to execute the steps of the page loading method according to any one of claims 1 to 7.
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.