Page loading method, device, computer equipment and storage medium
By filtering and prioritizing the page data in the server response message on the client side, and loading the web page data asynchronously, the problem of slow page loading speed caused by the time-consuming interaction of distributed systems is solved, and the web page loading efficiency and user experience are improved. .
Patent Information
- Application Number
- CN201811255726.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-10-26
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2038-10-26
AI Technical Summary
In the network, when the server responds to the client's page loading request, the web page loading speed is reduced due to the increase in distributed system interaction time.
By sending page request instructions to the server, receive response messages and use preset filter tags to match hypertext markup language tags, filter useless data, store remaining data in cache space, and load page data asynchronously according to priority.
The page loading efficiency is improved, important data is loaded first, resource consumption is reduced, and display problems caused by abnormal loading of some data are avoided.
Smart Images

Figure CN109582899B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a page loading method, device, computer equipment and storage medium. Background Art
[0002] With the rapid development of the Internet, applications and distributed systems in the Internet are becoming increasingly popular, and the Internet has brought many conveniences to people's lives. However, due to the increase in functional modules in the network and the increasing complexity of business logic, when the server responds to the client's page loading request, the data that needs to be called from the associated database must also increase accordingly. When the page needs to load more data, the loading speed of the client's web page decreases due to the increase in the time-consuming interaction between the server's distributed systems. Summary of the invention
[0003] Based on this, it is necessary to provide a page loading method, device, computer equipment and storage medium to solve the problem of low loading efficiency of web pages in response to the above technical problems.
[0004] A page loading method, comprising:
[0005] Send page request instructions to the server;
[0006] Receiving a response message returned by the server according to the page request instruction, and obtaining page data from the response message, wherein the response message includes at least two of the page data;
[0007] Using a preset filtering tag to match the hypertext markup language tag in each of the page data;
[0008] Filtering the page data corresponding to the successfully matched hypertext markup language tags, and storing the remaining page data after filtering as target page data in a preset cache space;
[0009] Determining the priority of each target page data according to a preset priority definition;
[0010] Each target page data in the cache space is asynchronously loaded into the display page in the order of priority of the target page data from high to low.
[0011] A page loading device, comprising:
[0012] Request sending module, used to send page request instructions to the server;
[0013] A message receiving module, used to receive a response message returned by the server according to the page request instruction, and obtain page data from the response message, wherein the response message includes at least two of the page data;
[0014] An information matching module, used for matching a preset filtering tag with a hypertext markup language tag in each of the page data;
[0015] A data filtering module, used for filtering the page data corresponding to the successfully matched hypertext markup language tags, and storing the remaining page data after filtering as target page data in a preset cache space;
[0016] A data distinguishing module, used for determining the priority of each target page data according to a preset priority definition;
[0017] The page loading module is used to asynchronously load each target page data in the cache space into a display page in the order of priority of the target page data from high to low.
[0018] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned page loading method when executing the computer program.
[0019] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned page loading method are implemented.
[0020] The above-mentioned page loading method, device, computer equipment and storage medium based on web page tags send a page request instruction to the server, obtain page data from the response message after receiving the response message returned by the server, use the preset filter tag to match the hypertext markup language tag in each page data, and filter the page data corresponding to the successfully matched hypertext markup language tag. At the same time, the remaining page data after filtering is stored in the preset cache space as the target page data, and finally the priority of each target page data is determined according to the preset priority definition, and the page data in the cache space is asynchronously loaded into the page in the order of the priority of the target page data from high to low. By filtering the page data that is not needed, and loading the returned page data into the display page in the order of the priority of the page data using asynchronous loading, it is possible to display the page data with higher importance to the user first, avoiding the situation where the display page cannot be displayed due to abnormal loading of some page data, so that the resources for page loading are reduced and the page loading efficiency is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0022] Figure 1 is a schematic diagram of an application environment of a page loading method in an embodiment of the present invention;
[0023] Figure 2 is a flow chart of a page loading method in one embodiment of the present invention;
[0024] Figure 3 yes Figure 2 A specific flow chart of step S20;
[0025] Figure 4 yes Figure 2 A specific flow chart of step S50;
[0026] Figure 5 It is a specific flow chart of preferentially loading target page data within a visible area in a page loading method in one embodiment of the present invention;
[0027] Figure 6 yes Figure 2 A specific flow chart of step S60;
[0028] Figure 7 is a principle block diagram of a page loading device in one embodiment of the present invention;
[0029] Figure 8 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0031] The page loading method provided in this application can be applied to Figure 1In an application environment, the application environment includes a server and a client, wherein the server and the client are connected via a network, a user sends a page request instruction to the server via the client, the server returns a response message to the client according to the page request instruction, the client filters the page data in the response message, and asynchronously loads the page data to the display page according to the priority of the page data. The client can specifically be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the server can specifically be implemented with an independent server or a server cluster consisting of multiple servers. An embodiment of the present invention provides a page loading method applied to a client.
[0032] In one embodiment, Figure 2 A flow chart of the page loading method in this embodiment is shown. The method is applied in Figure 1 The client in is used to asynchronously load the filtered page data into the display page. Figure 2 As shown, the page loading method includes steps S10 to S60, which are described in detail as follows:
[0033] S10: Send a page request instruction to the server.
[0034] Specifically, a page request instruction refers to a request for accessing a page sent by a user on the client to the server. For example, the client provides an interactive interface. When a user uses a browser on the client to access the resources of a web page, the client generates a page request instruction corresponding to the web page and sends it to the server based on the user's operation of requesting access to the web page on the interactive interface.
[0035] The page request instruction includes a URL (Uniform Resource Locator) address, which is used to uniquely identify the location where the resource corresponding to the web page requested to be accessed is stored on the Internet.
[0036] Preferably, the page request instruction can be sent asynchronously, and the client can use Ajax (Asynchronous JavaScript and XML) technology to execute asynchronous network requests, that is, the client uses JavaScript technology to asynchronously send page request instructions, and the page request instruction includes N threads, where N is a positive integer. For the resources of each functional module in the web page, a corresponding thread is created to request the server to obtain the data of the functional module. If the client receives the request data returned by the thread, JavaScript technology is used to update the page, so that the client can exchange data with the server and update part of the web page content without reloading the entire page, thereby realizing asynchronous update of the web page.
[0037] Among them, JavaScript is a scripting language used to add dynamic functions to web pages, and XML (Extensible Markup Language) is a markup language used to mark electronic files to make them structured, mark data transmitted between networks and define data types for easy identification by clients and servers.
[0038] S20: Receive a response message returned by the server according to the page request instruction, and obtain page data from the response message, wherein the response message includes at least two pages of data.
[0039] The response message includes a response status, a response header, and a response body.
[0040] The response status is identification information used to describe the response result of the server to the page request instruction. For example, a response status of "200" indicates that the client request is successful, and a response status of "404" indicates that the requested resource does not exist.
[0041] The response header includes but is not limited to the response time, response source, type of page data, and compression method of page data, among which the response source refers to the address of the responding server.
[0042] The response body includes page data constituting the web page, and the response body includes at least two pages of data.
[0043] Specifically, the client receives a response message returned by the server, and obtains page data from the response body of the response message. The page data is the resource corresponding to the web page requested for access, and is used to display data in the client's interactive interface. Each web page includes multiple page data.
[0044] In this embodiment, the server returns the response body in the form of HTML (Hyper Text Markup Language tag), that is, the page data is HTML code, and the page data includes HTML tags, which are attributes used to identify the page data. For example, if the HTML tag of the page data is <video>, it means that the attribute of the page data is video. If the HTML tag of the page data is <dialog>, it means that the attribute of the page data is a dialog box or window.
[0045] S30: Use the preset filtering tag to match the hypertext markup language tag in each page data.
[0046] In this embodiment, the preset filtering tag is an HTML tag used to filter useless data, where useless data refers to resources that users do not need to use on the web page, such as advertisements, smart recommendations, or sharing resources. When the loaded data does not belong to the resources that the user needs to obtain, it is useless data.
[0047] For example, the HTML tags for pop-up ads or smart recommendations are usually <dialog>Tags, you can <dialog>The tag is set as a filter tag, or the filter tag can also be customized according to the browsing needs of the user, which is not limited here.
[0048] Specifically, the client uses a preset filtering tag to match the hypertext markup language tag in each page data. If there is a tag in the preset filtering tag that is the same as the hypertext markup language tag of the page data, it means that the hypertext markup language tag is matched successfully, and the page data corresponding to the hypertext markup language tag is determined to be useless data. Otherwise, if the hypertext markup language tag of the page data is inconsistent with the preset filtering tag, it means that the hypertext markup language tag fails to match.
[0049] S40: filtering the page data corresponding to the successfully matched hypertext markup language tags, and storing the remaining page data after filtering as target page data in a preset cache space.
[0050] Specifically, the page data corresponding to the successfully matched hypertext markup language tags are filtered, useless data returned by the server response is eliminated, resources required by the user are retained, and the remaining page data after filtering is stored as target page data in a preset cache space, which is a storage space pre-set by the client for web page resources for storage requests.
[0051] Preferably, when the client issues a page request instruction, the client finds in the cache space a web page resource corresponding to the URL address in the page request instruction that has been cached, and then queries the server for the last modification time of the web page resource. If the last modification time of the web page resource returned by the server is consistent with the last modification time of the web page resource cached in the cache space, the client obtains the web page resource corresponding to the URL address in the page request instruction from the cache space, thereby saving the time for obtaining the web page resource and improving the page loading efficiency of the web page.
[0052] S50: Determine the priority of each target page data according to a preset priority definition.
[0053] Among them, the preset priority definition is used to distinguish the priority of the target page data. The higher the priority of the target page data, the more important the target page data is in the web page. The preset priority definition can be set according to the content of the target page data or the size of the target page data. There is no limitation here.
[0054] For example, if the target page data is a form element, it belongs to the first priority, and if the target page data is a non-form element, it belongs to the second priority, where form elements include but are not limited to text areas, list boxes, and input boxes, etc., and non-form elements include but are not limited to link tags, separator tags, and table tags, etc. The first priority is higher than the second priority.
[0055] S60: asynchronously loading each target page data in the cache space to the display page in descending order of priority of the target page data.
[0056] Specifically, according to the priority of each target page data determined in step S50, the target page data is obtained from the cache space in order of the priority of the target page data from high to low, the HTML code in the target page data is executed using the client's rendering engine, and the CSS (Cascading Style Sheets) style is loaded to determine the coordinates and size of each element in the target page data, and the target page data is rendered to the corresponding position of the web page, thereby asynchronously loading the target page data to the display page, wherein CSS is a computer language used to describe the style of files such as HTML or XML, and can perform pixel-level precise control on the layout of the element positions in the web page.
[0057] It is understandable that the client uses asynchronous loading to load the target page data of the web page separately, and prioritizes loading the target page data obtained from the server first. This improves the page loading efficiency compared to the client having to wait for the server to return all the resources corresponding to the web page and then load the web page at one time.
[0058] In this embodiment, by sending a page request instruction to the server, after receiving the response message returned by the server, the page data is obtained from the response message, the preset filter tag is used to match the hypertext markup language tag in each page data, and the page data corresponding to the successfully matched hypertext markup language tag is filtered, and at the same time, the remaining page data after filtering is stored as the target page data in the preset cache space, and finally the priority of each target page data is determined according to the preset priority definition, and the page data in the cache space is asynchronously loaded to the page in the order of the priority of the target page data from high to low. By filtering the page data that is not needed, and loading the returned page data into the display page in the order of the priority of the page data using asynchronous loading, it is possible to display the page data with higher importance to the user first, avoiding the situation where the display page cannot be displayed due to abnormal loading of some page data, reducing the resources for page loading, and improving the efficiency of page loading.
[0059] In one embodiment, this embodiment provides a detailed description of a specific implementation method of receiving a response message returned by the server according to a page request instruction and obtaining page data from the response message mentioned in step S20.
[0060] See also Figure 3 , Figure 3 A specific flow chart of step S20 is shown, which is described in detail as follows:
[0061] S201: Receive a response message returned by the server according to the page request instruction, wherein the response message includes a response body, and the response body exists in the response message in the form of a compressed file.
[0062] In this embodiment, the response message includes a response status, a response header and a response body. The response status includes identification information of the response result. The response header includes but is not limited to the response time, the response source, the type of page data and the compression method of the page data, etc. The response body includes the page data constituting the web page, and the response body includes at least two pages of data.
[0063] Specifically, the server parses the page request instruction, obtains the URL address corresponding to the page request instruction, obtains the corresponding web page resources as page data according to the URL address, compresses the page data according to the preset compression method, and uses data compression technology to obtain a response text, and generates a response message according to the response text, and transmits the response message to the client. The client receives the response message returned by the server through the network, wherein the preset compression method refers to the data compression technology pre-configured by the server, such as RAR compression technology or GZIP compression technology.
[0064] Preferably, the client can add the message "Accept-Encoding: gzip" in the page request instruction, indicating that the client requests GZIP-encoded data from the server. If the server supports GZIP encoding of data, the server can use a preset GZIP compression technology to compress the page data. The preset GZIP compression technology is a compression method pre-configured by the server. For example, the GZIP compression technology can be pre-configured in the Apache server or Nginx server on the server to compress the transmitted data, but it is not limited to this. It can be specifically set according to the actual application and is not limited here. Apache and Nginx are high-performance Web servers on the server.
[0065] It should be noted that GZIP is a data compression method. Using GZIP compression technology to compress data transmitted between networks can save 60% of transmission traffic and improve data transmission efficiency.
[0066] S202: Decompress the response body contained in the response message according to a preset decompression method to obtain page data.
[0067] Specifically, the client obtains the compression method of the page data from the response header of the response message, and uses a preset decompression method on the client to decompress the response body in the response message, thereby obtaining the page data, wherein the preset decompression method is a file decompression technology pre-configured by the client, which is used to decompress various types of compressed files on the client.
[0068] For example, if the response header of the response message contains the message "Content-Encoding: gzip", it means that the content encoding format of the page data is GZIP. The client calls the decompression method corresponding to the GZIP compression technology in the preset decompression method to decompress the response body according to the compression method of the acquired page data.
[0069] In this embodiment, by receiving a response message returned by the server according to the page request instruction, and decompressing the response body contained in the response message according to a preset decompression method, the page data is obtained, so that the client can receive the data compressed by the server using data compression technology, thereby reducing the amount of data transmitted over the network, saving network bandwidth, and using compressed data for transmission, which can improve data transmission efficiency, thereby improving page loading efficiency.
[0070] In one embodiment, this embodiment provides a detailed description of a specific implementation method for determining the priority of each target page data according to a preset priority definition mentioned in step S50.
[0071] See also Figure 4 , Figure 4 A specific flow chart of step S50 is shown, which is described in detail as follows:
[0072] S501: Obtaining a hypertext markup language tag of each target page data from the cache space.
[0073] Specifically, the page data includes a hypertext markup language tag, which is used to identify the attributes of the page data. The target page data is the resources that the user needs to use obtained by filtering the received page data. The hypertext markup language tag of each target page data is obtained from the cache space to determine the attributes of each target page data.
[0074] S502: According to the hypertext markup language tags of the target page data, query the priority tag corresponding to each hypertext markup language tag in the preset priority definition.
[0075] Specifically, the preset priority definition is a definition pre-set for distinguishing the priority of target page data. According to the hypertext markup language tag of the target page data, the priority tag corresponding to each hypertext markup language tag is queried in the preset priority definition. The higher the priority of the priority tag corresponding to the hypertext markup language tag, the higher the importance of the target page data corresponding to the hypertext markup language tag in the web page.
[0076] S503: Determine the priority of the target page data corresponding to the hypertext markup language tag according to the priority tag corresponding to the queried hypertext markup language tag.
[0077] Specifically, according to the priority tag corresponding to the queried hypertext markup language tag, the priority of the target page data corresponding to the hypertext markup language tag can be determined, so that the importance of each target page data in the requested web page can be known.
[0078] For example, the hypertext markup language tag of target page data A is , the hypertext markup language tag of the target page data B is <input> , the hypertext markup language tag of the target page data C is <title> , in the preset priority definition, the first priority tag includes< / title> <value> 、 <input> <title>、< / title> <href>and <nav>etc. The third priority tags include <video>, and <dialog>The client can query the priority tag corresponding to each hypertext markup language tag in the preset priority definition according to the hypertext markup language tag of the target page data, so as to obtain: Tags are at third priority, <input> Tags are at the first priority, <title> The tag is at the second priority, that is, the target page data A is at the third priority, the target page data B is at the first priority, and the target page data C is at the second priority, wherein the first priority is higher than the second priority, and the second priority is higher than the second priority.< / title>
[0079] In this embodiment, by obtaining the hypertext markup language tag of each target page data from the cache space, according to the hypertext markup language tag of the target page data, the priority tag corresponding to each hypertext markup language tag is queried in the preset priority definition, and according to the priority tag corresponding to the queried hypertext markup language tag, the priority of the target page data corresponding to the hypertext markup language tag is determined, thereby being able to know the importance of each target page data in the web page requested to be accessed, so that the client can output the target page data to the display page of the client according to the importance of the target page data.
[0080] In one embodiment, if Figure 5 As shown, after step S5, that is, after determining the priority of the target page data according to the preset priority definition, the page loading method further includes:
[0081] S51: Obtain the display size of the target page data and the size of the visualization window corresponding to the display page.
[0082] The display size of the target page data refers to the size of the target page data displayed when the target page data is loaded into the display page. The display size of the target page data can be obtained from the target page data. For example, the target page data is <img src=" / i / ct_1px.gif"width="200px"
[0083] height="30px" / >, indicating that the target page data is a picture with a width of 200px and a height of 30px, where px is a pixel unit and 200px means a size of 200 pixels.
[0084] It should be noted that if the target page data does not specify the display size of the element, the default display size preset by the client is used. For example, in the client's browser, the default font size of the text displayed on the web page is 16px.
[0085] Among them, the size of the visualization window corresponding to the display page refers to the visible area of the display page used by the client to display the web page. The size of the visualization window corresponding to the display page can be obtained by using the JavaScript code "document.body.clientWidth" to obtain the width of the display page, and using the JavaScript code "document.body.clientHeight" to obtain the height of the display page, thereby obtaining the size of the visualization window corresponding to the display page.
[0086] S52: Calculate the amount of page data that can be displayed in the visualization window according to the display size of the target page data and the size of the visualization window.
[0087] Specifically, the page data volume refers to the amount of target page data displayed on the display page. Specifically, the amount of page data that can be displayed in the visualization window can be calculated based on the display size of the target page data and the size of the visualization window, by dividing the size of the visualization window by the display size of the target page data.
[0088] S53: If the amount of page data in the cache space is greater than the amount of page data that can be displayed in the visualization window, determine the target page data that can be displayed in the visualization window according to a preset web page layout method, and use the target page data that can be displayed in the visualization window as the first loading data.
[0089] Specifically, the amount of page data in the cache space is counted. If the amount of page data in the cache space is larger than the amount of page data that can be displayed in the visualization window, the target page data that can be displayed in the visualization window is determined according to the preset web page layout method. The preset web page layout method refers to the service provider's pre-layout of the resources in the web page, which is used to define the position of each target resource data in the web page so that the web page achieves an aesthetically pleasing effect.
[0090] The server obtains the resources of the web page and the preset web page layout method corresponding to the web page and returns them to the client. The client can obtain the web page layout method corresponding to the web page from the response message, determine the target page data that can be displayed in the visualization window, and use the target page data that can be displayed in the visualization window as the first loading data.
[0091] S54: asynchronously loading the first loading data into the display page in descending order of priority of the target page data.
[0092] Specifically, according to the priority of each target page data determined in step S50, the first loaded data is asynchronously loaded into the display page in order of the priority of the target page data from high to low, wherein asynchronous loading means using the display page that has already loaded the target page data to interact with the target page data in the cache space, loading the target page data based on the already loaded display page, and realizing a partial update of the display page.
[0093] It is understandable that the size of the visible area of the display page used to display the web page in the client is limited. The target page data that can be displayed in the visualization window is used as the first loading data, and the first loading data is loaded preferentially using asynchronous loading, so that the user can read the resources in the visible area preferentially. At the same time, in the first loading data, the priority of the target page data is also different. The client can load the target page data in order from high to low priority, so that the user can obtain more important resources in the web page more quickly.
[0094] S55: If the first loaded data have all been loaded, then the target page data other than the first loaded data are asynchronously loaded into the display page in descending order of priority of the target page data.
[0095] Specifically, if the first loaded data has been loaded, it means that the data that can be displayed in the visualization window corresponding to the display page has been loaded. The target page data other than the first loaded data is asynchronously loaded to the display page in order of priority from high to low, so as to complete the loading of the entire web page.
[0096] It can be understood that the first loaded data is the target page data that can be displayed in the visualization window. The user first reads the resource corresponding to the first loaded data on the client, and the target page data other than the first loaded data can be delayed loaded.
[0097] In this embodiment, by obtaining the display size of the target page data and the size of the visualization window corresponding to the display page, the amount of page data that can be displayed in the visualization window is calculated, so as to determine whether the visualization window corresponding to the display page can fully display all the resources of the web page. If the amount of page data in the cache space is greater than the amount of page data that can be displayed in the visualization window, the target page data that can be displayed in the visualization window is determined according to the preset web page typesetting method, and the target page data that can be displayed in the visualization window is used as the first loading data. The first loading data is asynchronously loaded to the display page in order of the priority of the target page data from high to low, so that the user can read the resources in the visible area first. If the first loading data is completely loaded, the target page data other than the first loading data is asynchronously loaded to the display page in order of the priority of the target page data from high to low, so as to complete the loading of the entire web page.
[0098] In one embodiment, this embodiment provides a detailed description of a specific implementation method for asynchronously loading each target page data in the cache space to the display page in descending order of priority of the target page data mentioned in step S60.
[0099] See also Figure 6 , Figure 6 A specific flow chart of step S60 is shown, which is described in detail as follows:
[0100] S601: Determine the position of each target page data in the display page according to the preset web page layout, and use a preset placeholder to occupy the position of each target page data.
[0101] Specifically, the preset web page layout method refers to the service provider's pre-layout of the resources in the web page to define the position of each target resource data in the web page. The client can determine the position of each target page data in the display page according to the preset web page layout, and use the preset placeholder to occupy the position of each target page data.
[0102] The preset placeholder is used to occupy the position of the target page data in the display page. The preset placeholder plays a placeholder role in the display page, but will not be displayed in the display page of the client, and is used to wait for the writing of data.
[0103] S602: Obtain the target page data from the cache space in order of priority from high to low, determine the position of the target page data in the display page according to the hypertext markup language tag of the target page data, and write the target page data into a preset placeholder corresponding to the position so that the target page data is loaded into the display page.
[0104] Specifically, according to the priority of each target page data determined in step S50, the target page data is obtained from the cache space in descending order of priority, so that resources with higher importance in the web page are preferentially displayed on the display page.
[0105] According to the hypertext markup language tag of the target page data, the attributes of the target page data are determined, and in the preset web page layout, the position of the target page data corresponding to the hypertext markup language tag in the display page is queried, the HTML code in the target page data is executed, and the target page data is written into the preset placeholder corresponding to the position so that the target page data is loaded into the display page, thereby asynchronously loading the target page data into the display page.
[0106] In this embodiment, the position of each target page data in the display page is determined according to the preset web page layout, and the position of each target page data is occupied by a preset placeholder to avoid abnormal situations such as deformation during page loading. The target page data is obtained from the cache space in order of priority from high to low, and the position of the target page data in the display page is determined according to the hypertext markup language tag of the target page data, and the target page data is written into the preset placeholder corresponding to the position, so that the target page data is loaded into the display page, so that the client can give priority to loading resources with higher importance in the web page, thereby improving page loading efficiency.
[0107] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0108] In one embodiment, a page loading device is provided, which corresponds one-to-one to the page loading method in the above embodiment. Figure 7 As shown, the page loading device includes: a request sending module 71, a message receiving module 72, an information matching module 73, a data filtering module 74, a data distinguishing module 75 and a page loading module 76. The detailed description of each functional module is as follows:
[0109] The request sending module 71 is used to send a page request instruction to the server;
[0110] The message receiving module 72 is used to receive a response message returned by the server according to the page request instruction, and obtain the page data from the response message, wherein the response message includes at least two pages of data;
[0111] An information matching module 73, used to match the hypertext markup language tags in each page data using a preset filtering tag;
[0112] The data filtering module 74 is used to filter the page data corresponding to the successfully matched hypertext markup language tags, and store the remaining page data after filtering as the target page data in a preset cache space;
[0113] The data distinguishing module 75 is used to determine the priority of each target page data according to a preset priority definition;
[0114] The page loading module 76 is used to asynchronously load each target page data in the cache space into the display page in the order of priority of the target page data from high to low.
[0115] Furthermore, the message receiving module 72 includes:
[0116] The message receiving submodule is used to receive a response message returned by the server according to the page request instruction, wherein the response message includes a response body, and the response body exists in the response message in the form of a compressed file;
[0117] The data decompression submodule is used to decompress the response body contained in the response message according to a preset decompression method to obtain page data.
[0118] Furthermore, the data differentiation module 75 includes:
[0119] The tag acquisition submodule is used to acquire the hypertext markup language tag of each target page data from the cache space;
[0120] The tag query submodule is used to query the priority tag corresponding to each hypertext markup language tag in the preset priority definition according to the hypertext markup language tag of the target page data;
[0121] The level determination submodule is used to determine the priority of the target page data corresponding to the hypertext markup language tag according to the priority tag corresponding to the queried hypertext markup language tag.
[0122] Furthermore, the page loading device also includes:
[0123] A size acquisition module, used to acquire the display size of the target page data and the size of the visualization window corresponding to the display page;
[0124] A capacity calculation module, used to calculate the amount of page data that can be displayed in the visualization window according to the display size of the target page data and the size of the visualization window;
[0125] A data analysis module, for determining target page data that can be displayed in the visualization window according to a preset web page layout method if the amount of page data in the cache space is greater than the amount of page data that can be displayed in the visualization window, and using the target page data that can be displayed in the visualization window as the first loading data;
[0126] A priority loading module, used to asynchronously load the first loading data to the display page in descending order of priority of the target page data;
[0127] The delayed loading module is used to asynchronously load the target page data other than the first loading data to the display page in descending order of priority of the target page data if the loading of the first loading data is completed.
[0128] Furthermore, the page loading module 76 includes:
[0129] The preprocessing submodule is used to determine the position of each target page data in the display page according to the preset web page layout, and use the preset placeholder to occupy the position of each target page data;
[0130] The loading submodule is used to obtain the target page data from the cache space in the order of priority from high to low, and determine the position of the target page data in the display page according to the hypertext markup language tag of the target page data, and write the target page data into the preset placeholder corresponding to the position, so that the target page data is loaded into the display page.
[0131] For the specific definition of the page loading device, please refer to the definition of the page loading method above, which will not be repeated here. Each module in the above-mentioned page loading device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0132] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server through a network connection. When the computer program is executed by the processor, a page loading method is implemented.
[0133] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps in the page loading method of the above embodiment are implemented, such as Figure 2 Steps S10 to S60 shown in the figure, or when the processor executes the computer program, the functions of each module of the page loading device in the above embodiment are realized, for example Figure 7 The functions of modules 71 to 76 are shown in Figure 1. To avoid repetition, they will not be described here.
[0134] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned page loading method are implemented, such as Figure 2 Steps S10 to S60 shown in the figure, or when the processor executes the computer program, the functions of each module of the page loading device in the above embodiment are realized, for example Figure 7 The functions of modules 71 to 76 are shown in Figure 1. To avoid repetition, they will not be described here.
[0135] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0136] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0137] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.< / dialog> < / video> < / nav> < / href> and so on, the second priority tags include < / value> < / dialog> < / dialog> < / dialog> < / video>
Claims
1. A page loading method, characterized in that: The page loading method comprises: Send page request instructions to the server; Receiving a response message returned by the server according to the page request instruction, and obtaining page data from the response message, wherein the response message includes at least two of the page data; Using a preset filtering tag to match the hypertext markup language tag in each of the page data; Filtering the page data corresponding to the successfully matched hypertext markup language tags, and storing the remaining page data after filtering as target page data in a preset cache space; Determining the priority of each target page data according to a preset priority definition; Asynchronously loading each target page data in the cache space to a display page according to the priority order of the target page data from high to low; Determining the priority of each target page data according to a preset priority definition includes: Acquire the hypertext markup language tag of each target page data from the cache space; According to the hypertext markup language tags of the target page data, querying the priority tag corresponding to each hypertext markup language tag in the preset priority definition; The priority of the target page data corresponding to the hypertext markup language tag is determined according to the priority tag corresponding to the queried hypertext markup language tag.
2. The page loading method according to claim 1, characterized in that: The receiving a response message returned by the server according to the page request instruction, and obtaining page data from the response message includes: Receiving a response message returned by the server according to the page request instruction, wherein the response message includes a response body, and the response body exists in the response message in the form of a compressed file; The response body contained in the response message is decompressed according to a preset decompression method to obtain the page data.
3. The page loading method according to claim 1, characterized in that: After determining the priority of the target page data according to the preset priority definition, the page loading method further includes: Acquire the display size of the target page data and the size of the visualization window corresponding to the display page; Calculating the amount of page data that can be displayed in the visualization window according to the display size of the target page data and the size of the visualization window; If the amount of page data in the cache space is greater than the amount of page data that can be displayed in the visualization window, then according to a preset web page layout method, the target page data that can be displayed in the visualization window is determined, and the target page data that can be displayed in the visualization window is used as the first loading data; Asynchronously loading the first loading data to the display page in descending order of priority of the target page data; If the first loaded data have all been loaded, the target page data other than the first loaded data are asynchronously loaded into the display page in descending order of priority of the target page data.
4. The page loading method according to claim 3, characterized in that: The step of asynchronously loading each target page data in the cache space to the display page in descending order of priority of the target page data comprises: According to the preset web page layout, determine the position of each target page data in the display page, and use a preset placeholder to occupy the position of each target page data; The target page data is obtained from the cache space in order of priority from high to low, and the position of the target page data in the display page is determined according to the hypertext markup language tag of the target page data, and the target page data is written into the preset placeholder corresponding to the position, so that the target page data is loaded into the display page.
5. A page loading device, characterized in that: The page loading device comprises: Request sending module, used to send page request instructions to the server; A message receiving module, used to receive a response message returned by the server according to the page request instruction, and obtain page data from the response message, wherein the response message includes at least two of the page data; An information matching module, used for matching a preset filtering tag with a hypertext markup language tag in each of the page data; A data filtering module, used for filtering the page data corresponding to the successfully matched hypertext markup language tags, and storing the remaining page data after filtering as target page data in a preset cache space; A data distinguishing module, used for determining the priority of each target page data according to a preset priority definition; A page loading module, used for asynchronously loading each target page data in the cache space into a display page in descending order of priority of the target page data; The data distinguishing module comprises: The tag acquisition submodule is used to acquire the hypertext markup language tag of each target page data from the cache space; The tag query submodule is used to query the priority tag corresponding to each hypertext markup language tag in the preset priority definition according to the hypertext markup language tag of the target page data; The level determination submodule is used to determine the priority of the target page data corresponding to the hypertext markup language tag according to the priority tag corresponding to the queried hypertext markup language tag.
6. The page loading device according to claim 5, characterized in that: The page loading device also includes: A size acquisition module, used to acquire the display size of the target page data and the size of the visualization window corresponding to the display page; A capacity calculation module, used to calculate the amount of page data that can be displayed in the visualization window according to the display size of the target page data and the size of the visualization window; a data analysis module, configured to determine target page data that can be displayed in the visualization window according to a preset web page layout method if the amount of page data in the cache space is greater than the amount of page data that can be displayed in the visualization window, and use the target page data that can be displayed in the visualization window as first loading data; a priority loading module, configured to asynchronously load the first loading data into the display page in descending order of priority of the target page data; The delayed loading module is used to asynchronously load the target page data other than the first loading data to the display page in descending order of priority of the target page data if the loading of the first loading data is completed.
7. The page loading device according to claim 6, characterized in that: The page loading module includes: A preprocessing submodule, used to determine the position of each target page data in the display page according to the preset web page layout, and use a preset placeholder to occupy the position of each target page data; A loading submodule is used to obtain the target page data from the cache space in the order of priority of the target page data from high to low, and determine the position of the target page data in the display page according to the hypertext markup language tag of the target page data, and write the target page data into the preset placeholder corresponding to the position, so that the target page data is loaded into the display page.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the page loading method according to any one of claims 1 to 4 are implemented.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the page loading method according to any one of claims 1 to 4 are implemented.
