WO2020042328A1 - 页面加载方法及终端、页面响应方法及服务器 - Google Patents

页面加载方法及终端、页面响应方法及服务器 Download PDF

Info

Publication number
WO2020042328A1
WO2020042328A1 PCT/CN2018/113026 CN2018113026W WO2020042328A1 WO 2020042328 A1 WO2020042328 A1 WO 2020042328A1 CN 2018113026 W CN2018113026 W CN 2018113026W WO 2020042328 A1 WO2020042328 A1 WO 2020042328A1
Authority
WO
WIPO (PCT)
Prior art keywords
page
loaded
loading
quality parameter
page element
Prior art date
Application number
PCT/CN2018/113026
Other languages
English (en)
French (fr)
Inventor
郑家兴
Original Assignee
网宿科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 网宿科技股份有限公司 filed Critical 网宿科技股份有限公司
Priority to EP18931733.2A priority Critical patent/EP3843331A4/en
Priority to US16/486,118 priority patent/US20210357473A1/en
Publication of WO2020042328A1 publication Critical patent/WO2020042328A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/12Arrangements for remote connection or disconnection of substations or of equipment thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/04Protocols specially adapted for terminals or networks with limited capabilities; specially adapted for terminal portability
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching
    • H04L67/5681Pre-fetching or pre-delivering data based on network characteristics
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • H04L67/61Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources taking into account QoS or priority requirements
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Definitions

  • Embodiments of the present invention relate to the field of network technologies, and in particular, to a page loading method and terminal, a page response method, and a server.
  • webpages browsed by users generally include a variety of elements, such as html documents, JS scripts, and image resources, among which the largest proportion of webpage resources is generally image resources.
  • image resources When there are more image resources in the webpage, the loading speed of the webpage will be slower. If the user's network condition is poor, the loading time of the webpage will be further increased and the user experience will be poor. In view of this situation, if there are many image resources on the webpage, a lazy loading strategy can be adopted.
  • the image resources on the webpage load fuzzy images by default. When the user browses, the original image is loaded, which shortens the loading time of the webpage.
  • the purpose of the embodiments of the present invention is to provide a page loading method and terminal, a page response method and a server, which can improve the loading speed of a page.
  • an embodiment of the present invention provides a page loading method, which includes the following steps: applied to a terminal, the method includes: sending a page access request to a server, downloading page information returned by the server, and obtaining a download status of the page information ; Parse the load optimization script and the address information of the page element to be loaded from the page information; run the load optimization script and get the current loading quality parameters of the page element to be loaded according to the download of the page information; according to the address information of the page element to be loaded and The current loading quality parameter loads the page element to be loaded.
  • An embodiment of the present invention further provides a page response method, which is applied to a server.
  • the method includes: when a page access request sent by a terminal is received, obtaining page information corresponding to the page access request; and inserting a preset load into the page information Optimize script; return the page information including loading optimization script to the terminal for the terminal to parse the loading optimization script and the address information of the page element to be loaded from the page information, run the loading optimization script, and obtain the page element to be loaded according to the download of the page information The current loading quality parameter, and load the page element to be loaded according to the address information of the page element to be loaded and the current loading quality parameter.
  • An embodiment of the present invention further provides a terminal, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one The processor executes to enable at least one processor to execute the above-mentioned page loading method.
  • An embodiment of the present invention further provides a computer-readable storage medium storing a computer program, and the computer program is executed by a processor to implement the foregoing page loading method.
  • An embodiment of the present invention further provides a server, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor.
  • the processor executes to enable at least one processor to execute the page response method described above.
  • the terminal downloads the page information returned by the server and obtains the download status of the page information.
  • the terminal parses the load optimization script and the to-be-loaded page information from the page information.
  • the address information of the page element that is, the page information returned by the server includes the load optimization script and the address information of the page element to be loaded; subsequently, the terminal runs the load optimization script to obtain the current loading of the page element to be loaded according to the download of the page information Quality parameters, and load the page elements to be loaded according to the address information of the page elements to be loaded and the current loading quality parameters.
  • the corresponding current loading quality parameters are set for the page elements to be loaded according to the download information of the page information.
  • the page information is downloaded well, the page elements to be loaded with the higher quality are downloaded; and the page information is downloaded.
  • the page elements to be loaded include page elements to be loaded in the visible area and page elements to be loaded outside the visible area; loading the page elements to be loaded according to the address information of the page elements to be loaded and the current loading quality parameters include: According to the address information of the page element to be loaded in the visible area and the current loading quality parameters, load the page element to be loaded in the visible area and obtain the response of the page element to be loaded in the visible area; According to the response of the page element to be loaded, the current loading quality parameters are updated; according to the address information of the page element to be loaded outside the visible area and the updated current loading quality parameter, the page element to be loaded outside the visible area is loaded.
  • the current loading quality parameters obtained based on the download information of the page information alone may not be accurate enough
  • the response of the page element updates the current loading quality parameter, so as to obtain a more accurate loading quality parameter, and complete the loading of the page element to be loaded outside the visible area with the updated current loading quality parameter, thereby further improving the page Loading speed.
  • the method before loading the page elements outside the visible area based on the address information of the page elements to be loaded outside the visible area and the updated current loading quality parameters, the method further includes: monitoring page elements in the visible area, and Determine whether the page elements in the visible area have changed within the preset time period; when the page elements in the visible area have not changed within the preset time period, enter the information based on the address information of the page elements to be loaded outside the visible area and The updated current loading quality parameters, the steps of loading page elements to be loaded outside the visible area; when page elements in the visible area change within a preset duration, and there are unloaded to be loaded in the visible area A page element, and according to the address information of the unloaded page element to be loaded in the visible area and the updated current loading quality parameter, load the unloaded page element to be loaded in the visible area.
  • the page elements in the visible area are monitored. If the page elements in the visible area change within a preset time period and there are unloaded page elements to be loaded in the visible area, the visible area is loaded. Unloaded page elements to be loaded within; if the page elements in the visible area have not changed within a preset period of time, the page elements to be loaded outside the visible area are loaded, thereby reducing the concurrent loading of the page elements to be loaded, Improved loading speed of page elements to be loaded.
  • the number of page elements to be loaded in the visible area is multiple; the response conditions of the page elements to be loaded include the size of the page elements to be loaded and the response time period of the page elements to be loaded; according to the pages to be loaded in the visible area
  • the response of the element and updating the current loading quality parameters specifically include: when the response time periods of multiple page elements to be loaded do not overlap, obtaining the loading quality of each page element to be loaded according to the response situation of each page element to be loaded Parameter, and use the largest loading quality parameter among the loading quality parameters of multiple page elements to be loaded as the current loading quality parameter; when the response time periods of multiple page elements to be loaded overlap, there will be overlapping waiting periods of response time periods.
  • the loading page elements are divided into one group; according to the response of each group of page elements to be loaded, the loading quality parameters of each group of page elements to be loaded are obtained, and the largest loading quality parameter among the loading quality parameters of the plurality of groups of page elements to be loaded is taken as The currently loaded quality parameters.
  • This embodiment provides a specific implementation manner for updating a current loading quality parameter.
  • the response time period of the page elements to be loaded includes overlapping time periods and non-overlapping time periods; according to the response of each group of page elements to be loaded, the loading quality parameters of each group of page elements to be loaded include: For each page element to be loaded, the loading speed of the page elements to be loaded is calculated according to the size of the page elements to be loaded, the non-overlapping time period, the overlapping time period, and the number of overlapping times of the overlapping time period; according to each page element to be loaded in each group Size and loading speed, calculate the loading network bandwidth of each group of page elements to be loaded; use the loading quality parameter corresponding to the loading network bandwidth of each group of page elements to be loaded as the loading quality parameter of each group of page elements to be loaded.
  • This embodiment provides a specific implementation manner for obtaining loading quality parameters of each set of page elements to be loaded according to the response of each set of page elements to be loaded.
  • the method before loading the page element to be loaded according to the address information of the page element to be loaded and the current loading quality parameters, the method further includes: determining whether the same page element is cached in the terminal according to the address information of the page element to be loaded; The cache has the same page elements, and determines whether the loading quality parameter of the page element is greater than or equal to the current loading quality parameter; if the loading quality parameter of the page element is greater than or equal to the current loading quality parameter, the page element cached in the terminal is loaded; if the page element's The loading quality parameter is smaller than the loading quality parameter, or the same page element is not cached in the terminal, and a step of loading the page element to be loaded according to the address information of the page element to be loaded and the current loading quality parameter is entered.
  • the method further includes: caching the page element to be loaded and the current loading quality parameter.
  • the page elements to be loaded are loaded, the page elements to be loaded and their current loading quality parameters are cached to facilitate reloading the same page elements and directly obtained from the cache of the terminal.
  • obtaining the current loading quality parameters of the page elements to be loaded according to the download information of the page information specifically includes: calculating the current network bandwidth according to the download conditions of the page information; obtaining the loading quality parameters corresponding to the current network bandwidth as the elements of the page elements to be loaded The currently loaded quality parameters.
  • This embodiment provides a specific implementation manner for obtaining current loading quality parameters of a page element to be loaded according to a download situation of page information.
  • the page element to be loaded is an image.
  • FIG. 1 is a specific flowchart of a page loading method according to a first embodiment of the present invention
  • FIG. 2 is a specific flowchart of a page loading method according to a second embodiment of the present invention.
  • FIG. 3 is a specific flowchart of a page loading method according to a second embodiment of the present invention, in which substep 2042 is refined;
  • FIG. 4 is a specific flowchart of a page loading method according to a third embodiment of the present invention.
  • FIG. 5 is a specific flowchart of a page response method according to a fourth embodiment of the present invention.
  • the first embodiment of the present invention relates to a page loading method, which is applied to a terminal, such as a mobile phone, a tablet computer, or the like.
  • Step 101 Send a page access request to the server, download the page information returned by the server, and obtain the download status of the page information.
  • the terminal sends a page access request to the server.
  • the server receives a page access request
  • the server obtains the page information corresponding to the page access request and returns it to
  • the terminal downloads the page information returned by the server and can obtain the download status of the page information.
  • the page information may be an html document, and the download status of the page information includes the size of the page information, the response start time of the page information, and the response end time of the page information.
  • Step 102 Parse the loading optimization script and the address information of the page element to be loaded from the page information.
  • the page information includes the loading optimization script and the address information of the page elements to be loaded, so that when the terminal receives the page information, it performs dom analysis on the page information (html document), and parses the loading optimization script and Address information of the elements of the page to be loaded;
  • the loading optimization script may be inserted by the server into the page information corresponding to the page access request when the page access request is received, but it is not limited to this, and it may also be a time when the developer is developing the page Added in the page information in advance.
  • Step 103 Run the loading optimization script, and obtain the current loading quality parameters of the page elements to be loaded according to the downloading information of the page information.
  • the loading optimization script is run, and the current loading quality parameters of the page elements to be loaded are obtained according to the download information of the page information.
  • the current network bandwidth is calculated according to the download information of the page information. ;
  • the correspondence relationship between the network bandwidth and the loading quality parameter is pre-stored in the terminal, so that the loading quality parameter corresponding to the current network bandwidth can be obtained according to the correspondence relationship and used as the current loading quality parameter of the page element to be loaded; Determine what quality of the page element to load.
  • the specific way to calculate the current network bandwidth according to the download of page information is to calculate the download time of page information based on the response end time and response start time in the download of page information, and then divide the size of the page information by This download time can get the current network bandwidth.
  • Step 104 Load the page element to be loaded according to the address information of the page element to be loaded and the current loading quality parameter.
  • the terminal sends an acquisition request of the currently loaded quality parameter to the server according to the address information of the page element to be loaded.
  • the server determines whether the to-be-loaded page of the currently loaded quality parameter is cached. Element, if there is no cache, the page element to be loaded is compressed to obtain the page element to be loaded with the current loading quality parameter and returned to the terminal, and the terminal loads the page element to be loaded with the current loading quality parameter.
  • the page elements to be loaded may be pictures, videos, and the like.
  • the second embodiment of the present invention relates to a page loading method.
  • This embodiment is an improvement based on the first embodiment.
  • the main improvement is that the page loading speed is further improved.
  • the page elements to be loaded include page elements to be loaded in the visible area and page elements to be loaded outside the visible area.
  • steps 201 to 203 are substantially the same as steps 101 to 103, and are not repeated here.
  • step 204 includes the following sub-steps:
  • the terminal sends an acquisition request of the currently loaded quality parameter to the server according to the address information of the page element to be loaded in the visible area, and the server determines whether the current loading quality is cached after receiving the acquisition request.
  • the parameter of the page element to be loaded if there is no cache, the page element to be loaded is compressed to obtain the page element to be loaded with the current loading quality parameter and returned to the terminal, and the terminal loads the page element to be loaded with the current loading quality parameter in the visible area.
  • the terminal can obtain the response of the page element to be loaded in the visible area.
  • the response includes the size of the page element to be loaded and the response time period of the page element to be loaded.
  • the response time period of the page element to be loaded may be obtained according to the response start time of the page element to be loaded and the response end time of the page element to be loaded.
  • Sub-step 2042 Update the current loading quality parameter according to the response of the page element to be loaded in the visible area. Please refer to FIG. 3, sub-step 2042, including the following sub-steps:
  • Sub-step 20421 determining whether there is overlap in response time periods of multiple page elements to be loaded. If yes, go to sub-step 20422; if no, go to sub-step 20423.
  • the response time periods of multiple page elements to be loaded are arranged in ascending order, so that it can be determined whether there is an overlap in the response time periods of multiple page elements to be loaded, and the page elements to be loaded that have overlapping response time periods are parallel resources. ; If the response time periods of multiple page elements to be loaded overlap, go to sub-step 20422; otherwise, go to sub-step 20423.
  • the terminal divides the to-be-loaded page elements that have overlapping response time periods into a group, and for each to-be-loaded page element in each group, according to the size of the to-be-loaded page element, non-overlapping time period, overlapping time period, and The number of overlaps of the overlapping time period to calculate the loading speed of the page element to be loaded can be calculated according to the following formula:
  • the loading speed of the page element to be loaded the size of the page element to be loaded / (non-overlapping time period + overlapping time period * overlap frequency).
  • the loading network bandwidth of each page element to be loaded is calculated. Specifically, the size of each page element to be loaded in each group is compared with all the elements in the group. The ratio of the sum of the sizes of the page elements to be loaded is used as a weight value, and then each page element to be loaded is multiplied by the corresponding weight value and then added to calculate the loading network bandwidth of each group of page elements to be loaded.
  • a group of page elements to be loaded includes three page elements to be loaded, page element A to be loaded, page element B to be loaded, and page element C to be loaded.
  • the average value of the loading speed of the page elements to be loaded in each group may also be obtained as the loading network bandwidth of each group of page elements to be loaded, but this embodiment does not place any restrictions on this.
  • the loading quality parameters corresponding to the loading network bandwidth of each set of page elements to be loaded are obtained as the loading quality parameters of each set of page elements to be loaded, and multiple sets of The largest loading quality parameter among the loading quality parameters of the page element to be loaded is used as the current loading quality parameter.
  • Sub-step 20423 obtaining the loading quality parameter of each page element to be loaded according to the response of each page element to be loaded, and using the largest loading quality parameter among the loading quality parameters of the plurality of page elements to be loaded as the current loading quality parameter .
  • the ratio of the size of the page element to be loaded to the loading time period is taken as the loading network bandwidth of the page element to be loaded, and then each page to be loaded is obtained according to the correspondence between the network bandwidth and loading quality parameters stored in the terminal.
  • the loading quality parameter corresponding to the loading network bandwidth of the element is used as the loading quality parameter of each page element to be loaded, and the largest loading quality parameter among the loading quality parameters of the plurality of page elements to be loaded is used as the current loading quality parameter.
  • Sub-step 2043 Load the page elements to be loaded outside the visible area according to the address information of the page elements to be loaded outside the visible area and the updated current loading quality parameters.
  • the terminal sends an update request of the currently loaded quality parameter to the page element to be loaded to the server according to the address information of the page element to be loaded outside the visible area.
  • the server determines whether there is a cache The updated page element to be loaded with the currently loaded quality parameters is compressed. If there is no cache, the page element to be loaded is compressed to obtain the updated page element to be loaded with the currently loaded quality parameters and returned to the terminal.
  • the terminal loads updates outside the visible area. The page element to be loaded after the current loading quality parameter.
  • the current loading quality parameters are updated according to the response conditions of the page elements to be loaded in the visible area, but it is not limited to this.
  • a page except for the page elements to be loaded in the visible area
  • it also includes other resource requests.
  • the page taking the page element to be loaded as an example of an image, the page also includes a request for a fuzzy image.
  • the current loading quality parameters can be updated with the response status of all resource requests in the page.
  • the current loading quality parameters obtained based on the download information of the page information alone may not be accurate enough
  • the response of the page element to be loaded in the visible area updates the current loading quality parameter, so that a more accurate loading quality parameter can be obtained, and the updated current loading quality parameter completes the loading of the page element outside the visible area. Loading, which further improves the loading speed of the page.
  • the third embodiment of the present invention relates to a page loading method.
  • This embodiment is an improvement based on the first embodiment.
  • the main improvement is that a page element to be loaded can be obtained from a cache.
  • steps 301 to 303 are substantially the same as steps 101 to 103, and steps 307 and 104 are substantially the same, and will not be repeated here.
  • steps 304 to 306 are added, as follows:
  • Step 304 Determine whether the same page element is cached in the terminal according to the address information of the page element to be loaded. If yes, go to step 305; if no, go to step 307.
  • the terminal obtains from a cache of an application program such as a browser whether there is a page element with the same address as the page element to be loaded, and if the terminal has a page element with the same address as the page element to be loaded, proceed to step 305; On the contrary, it means that the terminal does not cache a page element with the same address as the page element to be loaded, and it proceeds to step 307 to load the page element to be loaded according to the address information of the page element to be loaded and the current loading quality parameter.
  • an application program such as a browser
  • Step 305 Determine whether the loading quality parameter of the page element is greater than or equal to the current loading quality parameter. If yes, go to step 306; if no, go to step 307.
  • step 306 it indicates that the quality of the page elements cached in the terminal is greater than the requested request to be loaded.
  • the quality of the page elements is poor. You cannot use the page elements cached in the terminal. You need to complete the loading of the page elements to be loaded with the current loading quality parameters.
  • Enter step 307 to load the to-be-loaded files based on the address information of the page elements to be loaded and the current loading quality parameters. Page element.
  • Step 306 Load page elements cached in the terminal.
  • the terminal obtains a page element that is the same as a page element to be loaded from a cache of an application such as a browser, and loads the page element.
  • Step 307 Load the page element to be loaded according to the address information of the page element to be loaded and the current loading quality parameter.
  • the method further includes:
  • step 308 the loaded page elements to be loaded and the current loading quality parameters are cached.
  • the terminal caches the page elements to be loaded into local storage, and at the same time, caches the current loading quality parameters as the loading quality parameters of the page elements to be loaded.
  • the page element cached in the terminal is updated, and the page element to be loaded is just loaded and the current loading quality parameter is used to replace the cache in the terminal.
  • a cache expiration time can also be configured for the page element to be loaded, so that it can be automatically deleted after the cache expiration time has elapsed, avoiding occupying the storage space of the terminal for a long time.
  • this embodiment determines whether the same page elements are cached in the terminal before loading the page elements to be loaded.
  • the terminal caches the same page elements, and the loaded quality parameter of the cached page elements is greater than Or is equal to the current loading quality parameter, the page element cached in the terminal is directly loaded, so that the page element to be loaded with a higher loading quality parameter can be obtained in the cache of the terminal.
  • this embodiment can also be an improvement based on the second embodiment, and can achieve the same technical effect.
  • the fourth embodiment of the present invention relates to a page response method, which is applied to a server.
  • the specific flow of the page response method in this embodiment is shown in FIG. 5.
  • Step 401 Determine whether a page access request sent by the terminal is received. If yes, go to step 402; if no, directly end.
  • the terminal when the user enters an access address in an application such as a browser of the terminal, the terminal sends a page access request to the server.
  • the server receives a page access request sent by the terminal, the server proceeds to step 402; otherwise, it ends directly. .
  • Step 402 Acquire page information corresponding to a page access request, and insert a preset loading optimization script into the page information.
  • the server obtains the page information corresponding to the page access request.
  • the page information is an html document.
  • the server inserts a preset load optimization script in the html document.
  • the server can insert a ⁇ / body> tag before the html document. Insert the load optimization script, but it is not limited to this.
  • the load optimization script can be inserted anywhere in the html document.
  • Step 403 Return the page information including the loading optimization script to the terminal.
  • the server returns the page information including the loading optimization script to the terminal, so that when the terminal obtains the page information, after the page information is dom-parsed, the terminal obtains the loading and loading optimization script and the address information of the page elements to be loaded; then, running Load the optimization script and calculate the current network bandwidth according to the download of the page information.
  • the correspondence between the network bandwidth and the loading quality parameter is pre-stored in the terminal, so that the loading quality parameter corresponding to the current network bandwidth can be obtained according to the correspondence and used as a standby
  • the current loading quality parameter of the loaded page element; thus, the quality of the page element to be loaded can be determined according to the current network bandwidth.
  • the specific way to calculate the current network bandwidth according to the download of page information is to calculate the download time of page information based on the response end time and response start time in the download of page information, and then divide the size of the page information by This download time can get the current network bandwidth.
  • the terminal sends an acquisition request of the page element to be loaded with the currently loaded quality parameter to the server according to the address information of the page element to be loaded.
  • the server determines whether the page element to be loaded with the currently loaded quality parameter is cached. If there is no cache, the page element to be loaded is compressed to obtain the page element to be loaded with the current loading quality parameter and returned to the terminal, and the terminal loads the page element to be loaded with the current loading quality parameter.
  • a load optimization module for monitoring a page access request of the terminal may be set in the terminal.
  • the load optimization module receives a page access request, it inserts a preset load into the page information corresponding to the page access request. Optimize the script; when receiving the request for the page element to be loaded with the current loading quality parameter, determine whether the page element to be loaded with the current loading quality parameter is cached; if there is no cache, the page element to be loaded is compressed to obtain the current loading quality parameter The page element to be loaded is returned to the terminal, and the terminal loads the page element to be loaded with current loading quality parameters.
  • the first embodiment corresponds to this embodiment, this embodiment can be implemented in cooperation with the first embodiment.
  • the related technical details mentioned in the first embodiment are still valid in this embodiment, and the technical effects that can be achieved in the first embodiment can also be achieved in this embodiment. In order to reduce repetition, details are not repeated here. Accordingly, the related technical details mentioned in this embodiment can also be applied in the first embodiment.
  • the terminal downloads the page information returned by the server and obtains the download information of the page information.
  • the terminal parses the load optimization script and the page to be loaded from the page information.
  • the address information of the element that is, the page information returned by the server includes the load optimization script and the address information of the page element to be loaded; subsequently, the terminal runs the load optimization script to obtain the current loading quality of the page element to be loaded according to the download of the page information Parameters, and load the page elements to be loaded according to the address information of the page elements to be loaded and the current loading quality parameters. That is, the corresponding current loading quality parameters are set for the page elements to be loaded according to the download information of the page information.
  • the page information is downloaded well, the page elements to be loaded with the higher quality are downloaded; and the page information is downloaded. When it is poor, download the lower-quality page elements to be loaded, thereby improving the loading speed of the page.
  • a fifth embodiment of the present invention relates to a terminal, such as a mobile phone, a tablet computer, and the like.
  • the terminal includes at least one processor; and a memory communicatively connected to the at least one processor; wherein,
  • the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the page loading method of any one of the first to third embodiments.
  • the memory and the processor are connected in a bus manner.
  • the bus may include any number of interconnected buses and bridges.
  • the bus connects one or more processors and various circuits of the memory together.
  • the bus can also connect various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art, and therefore, they will not be described further herein.
  • the bus interface provides an interface between the bus and the transceiver.
  • a transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium.
  • the data processed by the processor is transmitted on the wireless medium through the antenna. Further, the antenna also receives the data and transmits the data to the processor.
  • the processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions.
  • the memory can be used to store data used by the processor when performing operations.
  • a sixth embodiment of the present invention relates to a server including at least one processor; and a memory communicatively connected to the at least one processor; wherein,
  • the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute any one of the page response methods in the fourth embodiment.
  • a seventh embodiment of the present invention relates to a computer-readable storage medium storing a computer program.
  • the computer program is executed by the processor, the above method embodiment is implemented.
  • the program is stored in a storage medium and includes several instructions for making a device ( It may be a single-chip microcomputer, a chip, etc.) or a processor (processor) to perform all or part of the steps of the methods in the embodiments of the present application.
  • the foregoing storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disks or optical disks and other media that can store program codes .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明实施例涉及网络技术领域,公开了一种页面加载方法及终端、页面响应方法及服务器。页面加载方法,包括以下步骤:应用于终端,方法包括:向服务器发送页面访问请求,下载服务器返回的页面信息并得到页面信息的下载情况;从页面信息解析出加载优化脚本以及待加载页面元素的地址信息;运行加载优化脚本,并根据页面信息的下载情况得到待加载页面元素的当前加载质量参数;根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素。本发明中,提升了页面的加载速度。

Description

页面加载方法及终端、页面响应方法及服务器 技术领域
本发明实施例涉及网络技术领域,特别涉及一种页面加载方法及终端、页面响应方法及服务器。
背景技术
目前,用户浏览的网页一般包括多种元素,如html文档、JS脚本和图片资源等,其中占网页资源比最大的一般是图片资源。当网页中存在较多的图片资源时,网页的加载速度会比较慢,若用户的网络状况较差,则会进一步增长网页的加载时长,用户体验较差。针对这种情况,若网页中的图片资源较多,可以采用懒加载策略,网页中图片资源默认加载模糊图片,当用户浏览到时,才进行原图加载,从而缩短了网页的加载时长。
发明人发现现有技术中至少存在如下问题:即便采用了懒加载策略,如果用户网络较差,或者首屏中图片资源较多时,网页的加载时间仍然很长,用户体验较差。
发明内容
本发明实施方式的目的在于提供一种页面加载方法及终端、页面响应方法及服务器,提升了页面的加载速度。
为解决上述技术问题,本发明的实施方式提供了一种页面加载方法,包括以下步骤:应用于终端,方法包括:向服务器发送页面访问请求,下载服务器返回的页面信息并得到页面信息的下载情况;从页面信息解析出加载优化脚本以及待加载页面元素的地址信息;运行加载优化脚本,并根据页面信息的下载情况得到待加载页面元素的当前加载质量参数;根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素。
本发明的实施方式还提供了一种页面响应方法,应用于服务器,方法包括:当接收到终端发送的页面访问请求时,获取页面访问请求对应的页面信息;在页面信息中插入预设的加载优化脚本;向终端返回包括加载优化脚本的页面信息,以供终端从页面信息解析出加载优 化脚本以及待加载页面元素的地址信息,运行加载优化脚本,根据页面信息的下载情况得到待加载页面元素的当前加载质量参数,并根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素。
本发明的实施方式还提供了一种终端,包括:至少一个处理器;以及,与至少一个处理器通信连接的存储器;其中,存储器存储有可被至少一个处理器执行的指令,指令被至少一个处理器执行,以使至少一个处理器能够执行上述的页面加载方法。
本发明的实施方式还提供了一种计算机可读存储介质,存储有计算机程序,计算机程序被处理器执行时实现上述的页面加载方法。
本发明的实施方式还提供了一种服务器,包括:至少一个处理器;以及,与至少一个处理器通信连接的存储器;其中,存储器存储有可被至少一个处理器执行的指令,指令被至少一个处理器执行,以使至少一个处理器能够执行上述的页面响应方法。
本发明实施方式相对于现有技术而言,终端在向服务器发送页面访问请求后,下载服务器返回的页面信息并得到了页面信息的下载情况,终端从页面信息中解析出加载优化脚本以及待加载页面元素的地址信息,即服务器返回的页面信息中是包括加载优化脚本以及待加载页面元素的地址信息的;随后,终端运行加载优化脚本,根据页面信息的下载情况得到待加载页面元素的当前加载质量参数,并根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素。即,从而根据页面信息的下载情况来为待加载页面元素设定相应的当前加载质量参数,在页面信息的下载情况较好时,下载质量较高的待加载页面元素;在页面信息的下载情况较差时,下载质量较低的待加载页面元素,从而提升了页面的加载速度。
另外,待加载页面元素包括可视区域内的待加载页面元素和可视区域外的待加载页面元素;根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素,具体包括:根据可视区域内的待加载页面元素的地址信息和当前加载质量参数,加载可视区域内的待加载页面元素,并得到可视区域内的待加载页面元素的响应情况;根据可视区域内的待加载页面元素的响应情况,更新当前加载质量参数;根据可视区域外的待加载页面元素的地址信息与更新后的当前加载质量参数,加载可视区域外的待加载页面元素。本实施例中,在单独根据页面信息的下载情况得到的当前加载质量参数可能会不够准确的情况下,在完成可视区域内的待加载页面元素的加载后,根据可视区域内的待加载页面元素的响应情况更新当前加载质量参数,从而能够获取一个更为准确的加载质量参数,并以更新后的当前加载质量参数完成可视区域外的待加载页面元素的加载,从而进一步提升了页面的加载速度。
另外,在根据可视区域外的待加载页面元素的地址信息与更新后的当前加载质量参数, 加载可视区域外的待加载页面元素之前,还包括:监控可视区域内的页面元素,并判断可视区域内的页面元素在预设时长内是否发生变化;当可视区域内的页面元素在预设时长内未发生变化时,进入根据可视区域外的待加载页面元素的地址信息与更新后的当前加载质量参数,加载可视区域外的待加载页面元素的步骤;当可视区域内的页面元素在预设时长内发生变化时,且可视区域内的存在未加载的待加载页面元素,并根据可视区域内的未加载的待加载页面元素的地址信息与更新后的当前加载质量参数,加载可视区域内的未加载的待加载页面元素。本实施例中,监控可视区域内的页面元素,若可视区域内的页面元素在预设时长内发生变化,且可视区域内的存在未加载的待加载页面元素时,加载可视区域内的未加载的待加载页面元素;若可视区域内的页面元素在预设时长内未发生变化时,加载可视区域外的待加载页面元素,从而减少了待加载页面元素的并发加载,提升了待加载页面元素的加载速度。
另外,可视区域内的待加载页面元素的数量为多个;待加载页面元素的响应情况包括待加载页面元素的大小与待加载页面元素的响应时间段;根据可视区域内的待加载页面元素的响应情况,更新当前加载质量参数,具体包括:当多个待加载页面元素的响应时间段不存在重叠时,根据每个待加载页面元素的响应情况得到每个待加载页面元素的加载质量参数,并将多个待加载页面元素的加载质量参数中最大的加载质量参数,作为当前加载质量参数;当多个待加载页面元素的响应时间段存在重叠时,将响应时间段存在重叠的待加载页面元素分为一组;根据各组待加载页面元素的响应情况得到各组待加载页面元素的加载质量参数,并将多组待加载页面元素的加载质量参数中最大的加载质量参数,作为当前加载质量参数。本实施例提供了一种更新当前加载质量参数的具体实现方式。
另外,待加载页面元素的响应时间段包括重叠时间段与未重叠时间段;根据各组待加载页面元素的响应情况得到各组待加载页面元素的加载质量参数,具体包括:对于每组中的每个待加载页面元素,根据待加载页面元素的大小、未重叠时间段、重叠时间段以及重叠时间段的重叠次数,计算待加载页面元素的加载速度;根据每组中的各待加载页面元素的大小与加载速度,计算每组待加载页面元素的加载网络带宽;将每组待加载页面元素的加载网络带宽对应的加载质量参数,作为每组待加载页面元素的加载质量参数。本实施例提供了一种根据各组待加载页面元素的响应情况得到各组待加载页面元素的加载质量参数的具体实现方式。
另外,在根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素之前,还包括:根据待加载页面元素的地址信息,判断终端中是否缓存有相同的页面元素;若终端中缓存有相同的页面元素,判断页面元素的加载质量参数是否大于或等于当前加载质量 参数;若页面元素的加载质量参数大于或等于当前加载质量参数,加载终端中缓存的页面元素;若页面元素的加载质量参数小于加载质量参数,或终端中未缓存有相同的页面元素,进入根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素的步骤。本实施例中,在加载待加载页面元素之前,判断终端中是否缓存有相同的页面元素,当终端缓存有相同的页面元素,且缓存的页面元素的加载质量参数大于或等于当前加载质量参数时,直接加载终端中缓存的页面元素,从而能够在终端的缓存中获取加载质量参数更高的待加载页面元素。
另外,在根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素之后,还包括:缓存加载的待加载页面元素与当前加载质量参数。本实施方式中,在加载待加载页面元素之后,缓存待加载页面元素及其当前加载质量参数,便于重新加载相同的页面元素中,直接从终端的缓存中获取。
另外,根据页面信息的下载情况得到待加载页面元素的当前加载质量参数,具体包括:根据页面信息的下载情况,计算当前网络带宽;获取当前网络带宽对应的加载质量参数,作为待加载页面元素的当前加载质量参数。本实施方式提供了一种根据页面信息的下载情况得到待加载页面元素的当前加载质量参数的具体实现方式。
另外,待加载页面元素为图片。
附图说明
一个或多个实施例通过与之对应的附图中的图片进行示例性说明,这些示例性说明并不构成对实施例的限定,附图中具有相同参考数字标号的元件表示为类似的元件,除非有特别申明,附图中的图不构成比例限制。
图1是根据本发明第一实施方式的页面加载方法的具体流程图;
图2是根据本发明第二实施方式的页面加载方法的具体流程图;
图3是根据本发明第二实施方式的页面加载方法的具体流程图,其中对子步骤2042进行细化;
图4是根据本发明第三实施方式的页面加载方法的具体流程图;
图5是根据本发明第四实施方式的页面响应方法的具体流程图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合附图对本发明的各实施方式进行详细的阐述。然而,本领域的普通技术人员可以理解,在本发明各实施方式中,为了使读者更好地理解本申请而提出了许多技术细节。但是,即使没有这些技术细节和基于以下各实施方式的种种变化和修改,也可以实现本申请所要求保护的技术方案。
本发明的第一实施方式涉及一种页面加载方法,应用于终端,终端例如为手机、平板电脑等。
本实施方式的页面加载方法的具体流程如图1所示。
步骤101,向服务器发送页面访问请求,下载服务器返回的页面信息并得到页面信息的下载情况。
具体而言,当用户在终端的浏览器等应用程序中输入访问地址时,终端向服务器发送页面访问请求,服务器在接收到页面访问请求时,获取该页面访问请求对应的页面信息,并返回给终端,终端下载服务器返回的页面信息并能够得到页面信息的下载情况。其中,页面信息可以为一个html文档,页面信息的下载情况包括页面信息的大小、页面信息的响应开始时间以及页面信息的响应结束时间。
步骤102,从页面信息解析出加载优化脚本以及待加载页面元素的地址信息。
具体而言,页面信息中包括加载优化脚本以及待加载页面元素的地址信息,从而终端在接收到页面信息时,对页面信息(html文档)进行dom解析,从页面信息中解析出加载优化脚本与待加载页面的元素的地址信息;其中,加载优化脚本可以是服务器在接收到页面访问请求时,插入在页面访问请求对应的页面信息中,然不限于此,也可以是开发人员在开发页面时预先加入在页面信息中。
步骤103,运行加载优化脚本,并根据页面信息的下载情况得到待加载页面元素的当前加载质量参数。
具体而言,终端在解析出加载优化脚本后,运行加载优化脚本,根据页面信息的下载情况得到待加载页面元素的当前加载质量参数,具体的,根据页面信息的下载情况,计算得到当前网络带宽;终端中预存有网络带宽与加载质量参数的对应关系,从而能够根据该对应关系获取当前网络带宽对应的加载质量参数,并作为待加载页面元素的当前加载质量参数;从而能够根据当前网络带宽来确定加载何种质量的待加载页面元素。其中,根据页面信息的下载情况,计算得到当前网络带宽的具体方式为:根据页面信息的下载情况中的响应结束时间与响应开始时间可以计算出页面信息的下载时间,再页面信息的大小除以该下载时间便可以 得到当前网络带宽。
步骤104,根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素。
具体而言,终端根据待加载页面元素的地址信息向服务器发送当前加载质量参数的待加载页面元素的获取请求,服务器在接收到该获取请求后,判断是否缓存有当前加载质量参数的待加载页面元素,如果没有缓存,则对待加载页面元素进行压缩得到当前加载质量参数的待加载页面元素并返回给终端,终端加载当前加载质量参数的待加载页面元素。
本实施例中,待加载页面元素可以为图片、视频等。
本实施方式相对于现有技术而言,终端在向服务器发送页面访问请求后,下载服务器返回的页面信息并得到了页面信息的下载情况,终端从页面信息中解析出加载优化脚本以及待加载页面元素的地址信息,即服务器返回的页面信息中是包括加载优化脚本以及待加载页面元素的地址信息的;随后,终端运行加载优化脚本,根据页面信息的下载情况得到待加载页面元素的当前加载质量参数,并根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素。即,从而根据页面信息的下载情况来为待加载页面元素设定相应的当前加载质量参数,在页面信息的下载情况较好时,下载质量较高的待加载页面元素;在页面信息的下载情况较差时,下载质量较低的待加载页面元素,从而提升了页面的加载速度。
本发明的第二实施方式涉及一种页面加载方法,本实施方式是在第一实施方式基础上的改进,主要改进之处在于:进一步提升了页面的加载速度。
本实施方式的页面加载方法的具体流程如图2所示。本实施例中,待加载页面元素包括可视区域内的待加载页面元素和可视区域外的待加载页面元素
其中,步骤201至步骤203与步骤101至步骤103大致相同,在此不再赘述,主要不同之处在于,步骤204,包括以下子步骤:
子步骤2041,根据可视区域内的待加载页面元素的地址信息和当前加载质量参数,加载可视区域内的待加载页面元素,并得到可视区域内的待加载页面元素的响应情况。
具体而言,终端根据可视区域内的待加载页面元素的地址信息向服务器发送当前加载质量参数的待加载页面元素的获取请求,服务器在接收到该获取请求后,判断是否缓存有当前加载质量参数的待加载页面元素,如果没有缓存,则对待加载页面元素进行压缩得到当前加载质量参数的待加载页面元素并返回给终端,终端加载可视区域内的当前加载质量参数的待加载页面元素。同时,终端可以获取可视区域内的待加载页面元素的响应情况。响应情况包括待加载页面元素的大小与待加载页面元素的响应时间段。其中,待加载页面元素的响应时间段可以根据待加载页面元素的响应开始时间与待加载页面元素的响应结束时间来获得。
子步骤2042,根据可视区域内的待加载页面元素的响应情况,更新当前加载质量参数。请参考图3,子步骤2042,包括以下子步骤:
子步骤20421,判断多个待加载页面元素的响应时间段是否存在重叠。若是,则进入子步骤20422;若否,则进入子步骤20423。
具体而言,将多个待加载页面元素的响应时间段按照升序排列,从而能够判断出多个待加载页面元素的响应时间段是否存在重叠,响应时间段存在重叠的待加载页面元素为并行资源;若多个待加载页面元素的响应时间段存在重叠,则进入子步骤20422;反之,则进入子步骤20423。
较佳的,在判断多个待加载页面元素的响应时间段是否重叠之间,还可以先滤除多个待加载元素中的缓存请求与小资源请求(待加载页面元素的大小小于预设阈值),从而能够减小计算误差。
子步骤20422,将响应时间段存在重叠的待加载页面元素分为一组,根据各组待加载页面元素的响应情况得到各组待加载页面元素的加载质量参数,并将多组待加载页面元素的加载质量参数中最大的加载质量参数,作为当前加载质量参数。
具体而言,终端将响应时间段存在重叠的待加载页面元素分为一组,对于每组中的每个待加载页面元素,根据待加载页面元素的大小、未重叠时间段、重叠时间段以及重叠时间段的重叠次数,计算待加载页面元素的加载速度,具体可以按照如下公式来计算:待加载页面元素的加载速度=待加载页面元素的大小/(未重叠时间段+重叠时间段*重叠次数)。
然后,根据每组中的各待加载页面元素的大小与加载速度,计算每组待加载页面元素的加载网络带宽,具体的,以每组中的各待加载页面元素的大小与该组内所有待加载页面元素的大小的和之比作为权值,然后将各待加载页面元素乘以对应的权值后再相加,计算得到每组待加载页面元素的加载网络带宽。例如,某组待加载页面元素包括三个待加载页面元素,分别为待加载页面元素A、待加载页面元素B以及待加载页面元素C,三个待加载页面元素的大小与加载速度分别为(M A、S A)、(M B、S B)以及(M C、S C),则计算出来该组的待加载页面元素的加载网络带宽=S A*(M A/M A+M B+M C)+S B*(M B/M A+M B+M C)+S C*(M C/M A+M B+M C)。需要说明的是,本实施例中,还可以求每组中的待加载页面元素的加载速度的均值作为每组待加载页面元素的加载网络带宽,然本实施例对此不作任何限制。
最后,根据终端中预存的网络带宽与加载质量参数的对应关系,获取每组待加载页面元素的加载网络带宽对应的加载质量参数,作为每组待加载页面元素的加载质量参数,并将多组待加载页面元素的加载质量参数中最大的加载质量参数,作为当前加载质量参数。
子步骤20423,根据每个待加载页面元素的响应情况得到每个待加载页面元素的加载质量参数,并将多个待加载页面元素的加载质量参数中最大的加载质量参数,作为当前加载质量参数。
具体而言,将待加载页面元素的大小与加载时间段的比值作为该待加载页面元素的加载网络带宽,然后根据终端中预存的网络带宽与加载质量参数的对应关系,获取每个待加载页面元素的加载网络带宽对应的加载质量参数,作为每个待加载页面元素的加载质量参数,并将多个待加载页面元素的加载质量参数中最大的加载质量参数,作为当前加载质量参数。
子步骤2043,根据可视区域外的待加载页面元素的地址信息与更新后的当前加载质量参数,加载可视区域外的待加载页面元素。
具体而言,终端根据可视区域外的待加载页面元素的地址信息向服务器发送更新后的当前加载质量参数的待加载页面元素的获取请求,服务器在接收到该获取请求后,判断是否缓存有更新后的当前加载质量参数的待加载页面元素,如果没有缓存,则对待加载页面元素进行压缩得到更新后的当前加载质量参数的待加载页面元素并返回给终端,终端加载可视区域外的更新后的当前加载质量参数的待加载页面元素。
需要说明的是,本实施例中使用根据可视区域内的待加载页面元素的响应情况,更新当前加载质量参数,然不限于此,在一个页面中,除了可视区域内的待加载页面元素请求以外,还包括其他的资源请求,例如,以待加载页面元素为图片为例,页面中还包括模糊图请求,此时可以用页面中所有的资源请求的响应情况来更新当前加载质量参数。
本实施方式相对于第一实施方式而言,在单独根据页面信息的下载情况得到的当前加载质量参数可能会不够准确的情况下,在完成可视区域内的待加载页面元素的加载后,根据可视区域内的待加载页面元素的响应情况更新当前加载质量参数,从而能够获取一个更为准确的加载质量参数,并以更新后的当前加载质量参数完成可视区域外的待加载页面元素的加载,从而进一步提升了页面的加载速度。
本发明的第三实施方式涉及一种页面加载方法,本实施方式是在第一实施方式基础上的改进,主要改进之处在于:可以从缓存中获取待加载页面元素。
本实施方式的页面加载方法的具体流程如图4所示。
其中,步骤301至步骤303与步骤101至步骤103大致相同,步骤307与步骤104大致相同,在此不再赘述,主要不同之处在于,增加了步骤304至步骤306,具体如下:
步骤304,根据待加载页面元素的地址信息,判断终端中是否缓存有相同的页面元素。若是,进入步骤305;若否,进入步骤307。
具体而言,终端从浏览器等应用程序的缓存中获取是否有与待加载页面元素的地址相同的页面元素,若终端中缓存有与待加载页面元素的地址相同的页面元素,进入步骤305;反之,则说明终端没有缓存有与待加载页面元素的地址相同的页面元素,进入步骤307根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素。
步骤305,判断页面元素的加载质量参数是否大于或等于当前加载质量参数。若是,进入步骤306;若否,进入步骤307。
具体而言,在终端中缓存有与待加载页面元素的地址相同的页面元素时,判断终端中缓存的页面元素的加载质量参数是否大于或等于当前加载质量参数,若大于或等于,则说明终端中缓存的页面元素的质量至少是与所需请求的待加载页面元素的质量时相等的,此时,进入步骤306;反之,则说明终端中缓存的页面元素的质量比所需请求的待加载页面元素的质量差,不可以利用终端中缓存的页面元素,需要以当前加载质量参数完成待加载页面元素的加载,进入步骤307根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素。
步骤306,加载终端中缓存的页面元素。
具体而言,终端从浏览器等应用程序的缓存中获取与待加载页面元素相同的页面元素,并加载该页面元素。
步骤307,根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素。
在一个例子中,在步骤307之后,还包括:
步骤308,缓存加载的待加载页面元素与当前加载质量参数。
具体而言,终端在待加载页面元素加载完毕之后,将待加载页面元素缓存到本地存储中,同时,还缓存当前加载质量参数,作为待加载页面元素的加载质量参数;若终端中已经缓存有相同的页面元素,则对终端中缓存的页面元素进行更新,以刚刚加载待加载页面元素以及当前加载质量参数替换终端中的缓存。另外,在缓存待加载页面元素与当前加载质量参数时,还可以为该待加载页面元素配置一个缓存过期时间,从而能够在经过缓存过期时间后自动删除,避免长时间占据终端的存储空间。
本实施方式相对于第一实施方式而言,在加载待加载页面元素之前,判断终端中是否缓存有相同的页面元素,当终端缓存有相同的页面元素,且缓存的页面元素的加载质量参数大于或等于当前加载质量参数时,直接加载终端中缓存的页面元素,从而能够在终端的缓存中获取加载质量参数更高的待加载页面元素。需要说明的是,本实施方式还可以作为在第二实施方式基础上的改进,可以达到同样的技术效果。
本发明的第四实施方式涉及一种页面响应方法,应用于服务器。本实施方式的页面响应方法的具体流程如图5所示。
步骤401,判断是否接收到终端发送的页面访问请求。若是,则进入步骤402;若否,则直接结束。
具体而言,当用户在终端的浏览器等应用程序中输入访问地址时,终端会向服务器发送页面访问请求,服务器在接收到终端发送的页面访问请求时,进入步骤402;反之,则直接结束。
步骤402,获取页面访问请求对应的页面信息,并在页面信息中插入预设的加载优化脚本。
具体而言,服务器获取页面访问请求对应的页面信息,该页面信息是一个html文档,服务器在该html文档中插入预设的加载优化脚本,例如,可以在该html文档的</body>标签前插入加载优化脚本,然不限于此,加载优化脚本可以插入在html文档的任意位置。
步骤403,向终端返回包括加载优化脚本的页面信息。
具体而言,服务器向终端返回包括加载优化脚本的页面信息,从而终端在获取该页面信息时,对页面信息进行dom解析后,获取加载加载优化脚本以及待加载页面元素的地址信息;然后,运行加载优化脚本,根据页面信息的下载情况,计算得到当前网络带宽;终端中预存有网络带宽与加载质量参数的对应关系,从而能够根据该对应关系获取当前网络带宽对应的加载质量参数,并作为待加载页面元素的当前加载质量参数;从而能够根据当前网络带宽来确定加载何种质量的待加载页面元素。其中,根据页面信息的下载情况,计算得到当前网络带宽的具体方式为:根据页面信息的下载情况中的响应结束时间与响应开始时间可以计算出页面信息的下载时间,再页面信息的大小除以该下载时间便可以得到当前网络带宽。
随后,终端根据待加载页面元素的地址信息向服务器发送当前加载质量参数的待加载页面元素的获取请求,服务器在接收到该获取请求后,判断是否缓存有当前加载质量参数的待加载页面元素,如果没有缓存,则对待加载页面元素进行压缩得到当前加载质量参数的待加载页面元素并返回给终端,终端加载当前加载质量参数的待加载页面元素。
本实施例中,可以在终端中设置一个用于监听终端的页面访问请求的加载优化模块,该加载优化模块在接收到页面访问请求时,在页面访问请求对应的页面信息中插入预设的加载优化脚本;在接收到当前加载质量参数的待加载页面元素的获取请求时,判断是否缓存有当前加载质量参数的待加载页面元素,如果没有缓存,则对待加载页面元素进行压缩得到当前加载质量参数的待加载页面元素并返回给终端,终端加载当前加载质量参数的待加载页面元 素。
由于第一实施例与本实施例相互对应,因此本实施例可与第一实施例互相配合实施。第一实施例中提到的相关技术细节在本实施例中依然有效,在第一实施例中所能达到的技术效果在本实施例中也同样可以实现,为了减少重复,这里不再赘述。相应地,本实施例中提到的相关技术细节也可应用在第一实施例中。
本实施方式相对于现有技术而言,终端在向服务器发送页面访问请求后,下载服务器返回的页面信息并得到了页面信息的下载情况,终端从页面信息中解析出加载优化脚本以及待加载页面元素的地址信息,即服务器返回的页面信息中是包括加载优化脚本以及待加载页面元素的地址信息的;随后,终端运行加载优化脚本,根据页面信息的下载情况得到待加载页面元素的当前加载质量参数,并根据待加载页面元素的地址信息和当前加载质量参数,加载待加载页面元素。即,从而根据页面信息的下载情况来为待加载页面元素设定相应的当前加载质量参数,在页面信息的下载情况较好时,下载质量较高的待加载页面元素;在页面信息的下载情况较差时,下载质量较低的待加载页面元素,从而提升了页面的加载速度。
本发明第五实施方式涉及一种终端,例如手机、平板电脑等。终端包括至少一个处理器;以及,与至少一个处理器通信连接的存储器;其中,
存储器存储有可被至少一个处理器执行的指令,指令被至少一个处理器执行,以使至少一个处理器能够执行第一至第三实施例中任一的页面加载方法。
其中,存储器和处理器采用总线方式连接,总线可以包括任意数量的互联的总线和桥,总线将一个或多个处理器和存储器的各种电路连接在一起。总线还可以将诸如外围设备、稳压器和功率管理电路等之类的各种其他电路连接在一起,这些都是本领域所公知的,因此,本文不再对其进行进一步描述。总线接口在总线和收发机之间提供接口。收发机可以是一个元件,也可以是多个元件,比如多个接收器和发送器,提供用于在传输介质上与各种其他装置通信的单元。经处理器处理的数据通过天线在无线介质上进行传输,进一步,天线还接收数据并将数据传送给处理器。
处理器负责管理总线和通常的处理,还可以提供各种功能,包括定时,外围接口,电压调节、电源管理以及其他控制功能。而存储器可以被用于存储处理器在执行操作时所使用的数据。
本发明第六实施方式涉及一种服务器,包括至少一个处理器;以及,与至少一个处理器通信连接的存储器;其中,
存储器存储有可被至少一个处理器执行的指令,指令被至少一个处理器执行,以使至少 一个处理器能够执行第四实施例中任一的页面响应方法。
本发明第七实施方式涉及一种计算机可读存储介质,存储有计算机程序。计算机程序被处理器执行时实现上述方法实施例。
即,本领域技术人员可以理解,实现上述实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
本领域的普通技术人员可以理解,上述各实施方式是实现本发明的具体实施例,而在实际应用中,可以在形式上和细节上对其作各种改变,而不偏离本发明的精神和范围。

Claims (13)

  1. 一种页面加载方法,其特征在于,应用于终端,方法包括:
    向服务器发送页面访问请求,下载所述服务器返回的页面信息并得到所述页面信息的下载情况;
    从所述页面信息解析出加载优化脚本以及待加载页面元素的地址信息;
    运行所述加载优化脚本,并根据所述页面信息的下载情况得到所述待加载页面元素的当前加载质量参数;
    根据所述待加载页面元素的地址信息和所述当前加载质量参数,加载所述待加载页面元素。
  2. 根据权利要求1所述的页面加载方法,其特征在于,所述待加载页面元素包括可视区域内的待加载页面元素和可视区域外的待加载页面元素;所述根据所述待加载页面元素的地址信息和所述当前加载质量参数,加载所述待加载页面元素,具体包括:
    根据所述可视区域内的所述待加载页面元素的地址信息和所述当前加载质量参数,加载所述可视区域内的所述待加载页面元素,并得到所述可视区域内的所述待加载页面元素的响应情况;
    根据所述可视区域内的所述待加载页面元素的响应情况,更新所述当前加载质量参数;
    根据所述可视区域外的所述待加载页面元素的地址信息与更新后的所述当前加载质量参数,加载所述可视区域外的所述待加载页面元素。
  3. 根据权利要求2所述的页面加载方法,其特征在于,在所述根据所述可视区域外的所述待加载页面元素的地址信息与更新后的所述当前加载质量参数,加载所述可视区域外的所述待加载页面元素之前,还包括:
    监控所述可视区域内的页面元素,并判断所述可视区域内的页面元素在预设时长内是否发生变化;
    当所述可视区域内的页面元素在预设时长内未发生变化时,进入所述根据所述可视区域外的所述待加载页面元素的地址信息与更新后的所述当前加载质量参数,加载所述可视区域外的所述待加载页面元素的步骤;
    当所述可视区域内的页面元素在预设时长内发生变化时,且所述可视区域内的存在未加载的所述待加载页面元素,并根据所述可视区域内的未加载的所述待加载页面元素的地址信息与更新后的所述当前加载质量参数,加载所述可视区域内的未加载的所述待加载页面元素。
  4. 根据权利要求2所述的页面加载方法,其特征在于,所述可视区域内的待加载页面元素的数量为多个;所述待加载页面元素的响应情况包括所述待加载页面元素的大小与所述待加载页面元素的响应时间段;
    所述根据所述可视区域内的所述待加载页面元素的响应情况,更新所述当前加载质量参数,具体包括:
    当多个所述待加载页面元素的响应时间段不存在重叠时,根据每个所述待加载页面元素的响应情况得到每个所述待加载页面元素的加载质量参数,并将多个所述待加载页面元素的加载质量参数中最大的加载质量参数,作为所述当前加载质量参数;
    当多个所述待加载页面元素的响应时间段存在重叠时,将响应时间段存在重叠的所述待加载页面元素分为一组,根据各组所述待加载页面元素的响应情况得到各组所述待加载页面元素的加载质量参数,并将多组所述待加载页面元素的加载质量参数中最大的加载质量参数,作为所述当前加载质量参数。
  5. 根据权利要求4所述的页面加载方法,其特征在于,所述待加载页面元素的响应时间段包括重叠时间段与未重叠时间段;所述根据各组所述待加载页面元素的响应情况得到各组所述待加载页面元素的加载质量参数,具体包括:
    对于每组中的每个所述待加载页面元素,根据所述待加载页面元素的大小、未重叠时间段、重叠时间段以及所述重叠时间段的重叠次数,计算所述待加载页面元素的加载速度;
    根据每组中的各所述待加载页面元素的大小与所述加载速度,计算每组所述待加载页面元素的加载网络带宽;
    将每组所述待加载页面元素的加载网络带宽对应的加载质量参数,作为每组所述待加载页面元素的加载质量参数。
  6. 根据权利要求1所述的页面加载方法,其特征在于,在所述根据所述待加载页面元素的地址信息和所述当前加载质量参数,加载所述待加载页面元素之前,还包括:
    根据所述待加载页面元素的地址信息,判断所述终端中是否缓存有相同的页面元素;
    若所述终端中缓存有相同的页面元素,判断所述页面元素的加载质量参数是否大于或等于所述当前加载质量参数;
    若所述页面元素的加载质量参数大于或等于所述当前加载质量参数,加载所述终端中缓存的所述页面元素;
    若所述页面元素的加载质量参数小于所述加载质量参数,或所述终端中未缓存有相同的页面元素,进入所述根据所述待加载页面元素的地址信息和所述当前加载质量参数,加载所 述待加载页面元素的步骤。
  7. 根据权利要求1所述的页面加载方法,其特征在于,在所述根据所述待加载页面元素的地址信息和所述当前加载质量参数,加载所述待加载页面元素之后,还包括:
    缓存加载的所述待加载页面元素与所述当前加载质量参数。
  8. 根据权利要求1所述的页面加载方法,其特征在于,所述根据所述页面信息的下载情况得到所述待加载页面元素的当前加载质量参数,具体包括:
    根据所述页面信息的下载情况,计算当前网络带宽;
    获取所述当前网络带宽对应的加载质量参数,作为所述待加载页面元素的当前加载质量参数。
  9. 根据权利要求1所述的页面加载方法,其特征在于,所述待加载页面元素为图片。
  10. 一种页面响应方法,其特征在于,应用于服务器,所述方法包括:
    当接收到终端发送的页面访问请求时,获取所述页面访问请求对应的页面信息,并在所述页面信息中插入预设的加载优化脚本;
    向所述终端返回包括所述加载优化脚本的所述页面信息,以供所述终端从所述页面信息解析出加载优化脚本以及待加载页面元素的地址信息,运行所述加载优化脚本,根据所述页面信息的下载情况得到所述待加载页面元素的当前加载质量参数,并根据所述待加载页面元素的地址信息和所述当前加载质量参数,加载所述待加载页面元素。
  11. 一种终端,其特征在于,包括:至少一个处理器;以及,
    与所述至少一个处理器通信连接的存储器;其中,
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如权利要求1至9中任一所述的页面加载方法。
  12. 一种计算机可读存储介质,存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1至9中任一项所述的页面加载方法。
  13. 一种服务器,其特征在于,包括:至少一个处理器;以及,
    与所述至少一个处理器通信连接的存储器;其中,
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如权利要求10所述的页面响应方法。
PCT/CN2018/113026 2018-08-29 2018-10-31 页面加载方法及终端、页面响应方法及服务器 WO2020042328A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP18931733.2A EP3843331A4 (en) 2018-08-29 2018-10-31 PAGE LOADING PROCESS, TERMINAL, PAGE RESPONSE PROCESS AND SERVER
US16/486,118 US20210357473A1 (en) 2018-08-29 2018-10-31 Page-loading method and terminal, and page-responding method and server

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810993928.2 2018-08-29
CN201810993928.2A CN109284464B (zh) 2018-08-29 2018-08-29 页面加载方法及终端、页面响应方法及服务器

Publications (1)

Publication Number Publication Date
WO2020042328A1 true WO2020042328A1 (zh) 2020-03-05

Family

ID=65184143

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/113026 WO2020042328A1 (zh) 2018-08-29 2018-10-31 页面加载方法及终端、页面响应方法及服务器

Country Status (4)

Country Link
US (1) US20210357473A1 (zh)
EP (1) EP3843331A4 (zh)
CN (1) CN109284464B (zh)
WO (1) WO2020042328A1 (zh)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110347446B (zh) * 2019-07-16 2022-11-25 创新先进技术有限公司 一种页面资源加载方法及系统
CN112395535A (zh) * 2019-08-15 2021-02-23 腾讯科技(深圳)有限公司 图片的懒加载方法及装置、介质和电子设备
CN110889074B (zh) * 2019-11-27 2022-04-08 珠海格力电器股份有限公司 页面显示方法、装置、存储介质及电子设备
CN111125581B (zh) * 2019-12-13 2021-03-16 北京金堤科技有限公司 图片加载方法以及装置
CN113485778B (zh) * 2021-06-25 2023-06-13 青岛海尔科技有限公司 页面数据的处理方法、装置、存储介质和电子装置
CN114518912B (zh) * 2022-02-21 2023-04-25 度小满科技(北京)有限公司 一种页面加载方法、装置、设备及可读存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010052003A1 (en) * 2000-03-29 2001-12-13 Ibm Corporation System and method for web page acquisition
CN104063392A (zh) * 2013-03-20 2014-09-24 腾讯科技(深圳)有限公司 一种阅读内容的加载方法及装置
CN104462249A (zh) * 2014-11-19 2015-03-25 北京奇虎科技有限公司 网页加载方法和装置
CN104778285A (zh) * 2015-05-12 2015-07-15 成都广达电子股份有限公司 一种基于xml的web服务系统及其工作方法
CN105530292A (zh) * 2015-12-01 2016-04-27 小米科技有限责任公司 页面图像显示方法及装置

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101996184A (zh) * 2009-08-13 2011-03-30 上海杉达学院 建立供移动终端访问的移动网站的方法
US9503510B2 (en) * 2012-03-10 2016-11-22 Headwater Partners Ii Llc Content distribution based on a value metric
CN102902799B (zh) * 2012-10-12 2015-08-12 中科方德软件有限公司 一种基于WebKit的浏览器页面显示方法及其装置
US9619439B1 (en) * 2013-02-26 2017-04-11 Google Inc. Incremental web font loading
CN105653933B (zh) * 2016-01-06 2019-04-30 北京京东尚科信息技术有限公司 插件加载方法及装置
CN106503272B (zh) * 2016-12-15 2019-10-29 深圳Tcl数字技术有限公司 浏览器网页显示方法及装置
CN106874434A (zh) * 2017-01-24 2017-06-20 青岛海信电器股份有限公司 一种网页数据处理、网页加载方法及相关装置
CN108196964A (zh) * 2017-12-29 2018-06-22 北京奇虎科技有限公司 一种将数据流模块化的方法和装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010052003A1 (en) * 2000-03-29 2001-12-13 Ibm Corporation System and method for web page acquisition
CN104063392A (zh) * 2013-03-20 2014-09-24 腾讯科技(深圳)有限公司 一种阅读内容的加载方法及装置
CN104462249A (zh) * 2014-11-19 2015-03-25 北京奇虎科技有限公司 网页加载方法和装置
CN104778285A (zh) * 2015-05-12 2015-07-15 成都广达电子股份有限公司 一种基于xml的web服务系统及其工作方法
CN105530292A (zh) * 2015-12-01 2016-04-27 小米科技有限责任公司 页面图像显示方法及装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3843331A4 *

Also Published As

Publication number Publication date
US20210357473A1 (en) 2021-11-18
CN109284464A (zh) 2019-01-29
CN109284464B (zh) 2021-07-23
EP3843331A4 (en) 2021-08-25
EP3843331A1 (en) 2021-06-30

Similar Documents

Publication Publication Date Title
WO2020042328A1 (zh) 页面加载方法及终端、页面响应方法及服务器
US10489476B2 (en) Methods and devices for preloading webpages
WO2017036309A1 (zh) 页面渲染方法、装置及设备
CN106776761B (zh) 一种移动浏览器渲染网页的方法及装置
KR102151457B1 (ko) 통신 시스템에서 페이지 로딩 시간 단축 방법 및 장치
US9619388B2 (en) Method for managing cache data of a mobile terminal, mobile terminal, and server
CN109376318B (zh) 一种页面加载方法、计算机可读存储介质及终端设备
US20150371142A1 (en) Predicting next web pages
EP3866030A1 (en) Webpage loading method, intermediate server, and webpage loading system
US20140143647A1 (en) Method for improving browser cache by reducing duplicate stored content
US10862992B2 (en) Resource cache management method and system and apparatus
CN111984351A (zh) 页面适配方法、电子设备、计算机可读存储介质
CN108920703B (zh) 一种http缓存优化方法与装置
WO2022104754A1 (zh) 网络资源的管理方法、管理装置、电子设备及存储介质
US20200320154A1 (en) A webpage loading method, webpage loading system and server
KR102112605B1 (ko) 모바일 단말 및 모바일 단말의 네트워크 전송 제어 방법
JP2021174129A (ja) Api課金システム及びapi課金管理方法
CN112926002A (zh) 一种服务请求的处理方法及装置
CN109344351B (zh) 网页加载方法、中间服务器和网页加载系统
US11134116B2 (en) System and method for dynamically loading a webpage
CN115470427A (zh) 页面加载方法、装置、设备以及存储介质
CN109857966A (zh) 一种浏览器动态加载网页资源的优化方法及浏览器
CN115455097A (zh) 风控数据处理方法、系统、计算机设备及存储介质
US20140237133A1 (en) Page download control method, system and program for ie core browser
CN111753232B (zh) 第三方h5页面加载的方法、装置及计算机可读存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18931733

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2018931733

Country of ref document: EP

Effective date: 20210324