Page rendering method and device, electronic equipment and storage medium

By using server-side pre-rendering and data caching technologies, the problem of slow page rendering speed on low-performance devices is solved, enabling fast rendering and generation of interactive pages.

CN121479072APending Publication Date: 2026-02-06BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511450988.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-11
Publication Date
2026-02-06

AI Technical Summary

Technical Problem

On devices with lower performance, the server-side rendering of pages relies on the UI framework, resulting in slow initial screen display, white screen, and lag issues.

Method used

The server pre-renders the page, generates a static page, and injects the main identifiers of data reading code and event code. The client executes the necessary event code based on the identifiers, skips the already executed server-side code, and reduces the loading of framework code.

Benefits of technology

It improves page rendering speed, especially on resource-constrained devices, reduces framework code loading time, and enhances first-screen display efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121479072A_ABST
    Figure CN121479072A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a page rendering method and device, electronic equipment and a storage medium, and relates to the technical field of internet application, the method is applied to a server side, and the method comprises the following steps: receiving a page data acquisition request for a to-be-generated page; obtaining a code file of the to-be-generated page, wherein the code file comprises an event code; obtaining first page typesetting, updating the current page typesetting of the to-be-generated page, and executing an event code of which the main body identifier is executed by the server side to obtain interface data of a first window in the page typesetting; based on the interface data and the first page typesetting, pre-rendering the to-be-generated page to obtain a pre-rendered page; and caching the main body identifiers of the data reading code, the interface data and the event code to a page script by utilizing the data writing code, injecting the main body identifiers into the pre-rendered page and returning the main body identifiers to the client, so that the client loads the pre-rendered page by utilizing the data reading code based on the page script to obtain a target page. According to the embodiment of the invention, the page rendering speed is increased.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Internet application, and in particular to a page rendering method and device, electronic equipment and storage medium. BACKGROUND

[0002] The server-side rendering page refers to a web page rendering mode generated by the server and sent to the client. In the prior art, the server-side rendering page depends on the ui framework implementation, such as react, vue (ui framework based on dynamic programming language). The server-side rendering is a first screen page without page function and page code execution. After the client receives and renders the first screen page, the component tool provided by the framework is loaded, and the page code is executed by using the component tool to realize the basic page function such as page interaction monitoring, and finally the page is obtained.

[0003] In this framework scenario, in theory, the client can render and display after receiving the first screen page, and the subsequent loading of the component tool can realize user perception. However, when the client runs on a device with low performance, such as a browser kernel version or a cpu (central processing unit) with low performance, due to the lack of intelligent browser kernel scheduling or the manufacturer's modification of the system, many clients actually need to wait for the component tool to be loaded before rendering the first screen page. Because in the framework scenario, most of the component tools must be loaded to execute the page code, the loading of too many useless component tools slows down the first screen display speed, and brings the problems of poor experience such as white screen and lag. SUMMARY

[0004] The purpose of the embodiment of the present application is to provide a page rendering method, device, electronic equipment and storage medium to improve the speed of page rendering. The specific technical solution is as follows:

[0005] In a first aspect, the embodiment of the present application provides a page rendering method applied to a server, comprising:

[0006] Receiving a page data acquisition request sent by a client for a to-be-generated page;

[0007] Based on the page data acquisition request, a code file of the to-be-generated page is obtained, wherein the code file includes event code of each window in the page, and the event code has a subject identifier, which indicates that the event code of the window is executed by the server or the client;

[0008] Obtaining a first page layout required for displaying the to-be-generated page, updating the current page layout of the to-be-generated page based on the first page layout, and executing the event code of the subject identifier for server execution to obtain interface data of a first window in the page layout;

[0009] based on the interface data and the first page layout, pre-render the to-be-generated page to obtain a pre-rendered page, wherein the pre-rendered page is a static page;

[0010] by using the data writing code, cache the data reading code, the interface data and the subject identifier of the event code to a page script, inject the pre-rendered page, and return to the client, so that the client loads the pre-rendered page by using the data reading code based on the page script to obtain a target page, wherein the target page is an interactive page, and the data writing code and the data reading code are corresponding page script data processing codes.

[0011] In an embodiment of the present application, the identifier of the event code further comprises a state identifier, which represents the current execution state of the event code, and after obtaining the first page layout required by the to-be-generated page for display, updating the current page layout of the to-be-generated page based on the first page layout, and executing the event code with the subject identifier executed by the server, obtaining the interface data of the first window in the page layout, the method further comprises:

[0012] detecting whether the event code with the subject identifier executed by the server is successfully executed;

[0013] if yes, updating the state identifier of the event code to successfully executed, otherwise, updating the state identifier of the event code to unsuccessfully executed;

[0014] caching the state identifier of the event code to the page script.

[0015] In an embodiment of the present application,

[0016] The page script is a script script, the script script is injected to the front of the page code of the pre-rendered page, and the data reading code is used to read the interface data, the state identifier and the subject identifier.

[0017] In a second aspect, an embodiment of the present application provides a page rendering method applied to a client, comprising:

[0018] sending a page data obtaining request for a to-be-generated page to a server;

[0019] in the case of receiving a request response returned by the server, obtaining a pre-rendered page in the request response, wherein the pre-rendered page is a static page, and the pre-rendered page is obtained based on a page layout required by the to-be-generated page for display and interface data of a window in the page layout;

[0020] execute the page code of the pre-rendered page, obtain a page script from the page code, wherein the page script comprises data reading code, interface data generated by the server, and a subject identifier of event code, and the subject identifier indicates that the event code of each window of the pre-rendered page is executed by the server or the client;

[0021] read the interface data by using the data reading code, fill the interface data into a first window of a page layout of the pre-rendered page, and render the pre-rendered page;

[0022] read the subject identifier by using the data reading code, execute the event code of the pre-rendered page whose subject identifier is the client, and obtain event data of a second window of the page layout of the pre-rendered page;

[0023] fill the event data into the second window of the page layout of the pre-rendered page, and generate a target page, wherein the target page is an interactive page.

[0024] In an embodiment of the present application, the page script further comprises a state identifier of the event code, the state identifier indicates a current execution state of the event code, and the filling of the event data into the second window of the page layout of the pre-rendered page and the generation of the target page comprises:

[0025] read the state identifier by using the data reading code, execute the event code whose state identifier is not successfully executed, and obtain interface data of a third window of the page layout of the pre-rendered page;

[0026] fill the event data into the second window of the page layout of the pre-rendered page, fill the interface data of the third window into the third window of the page layout of the pre-rendered page, and generate the target page.

[0027] In an embodiment of the present application, in the case that the pre-rendered page returned by the server is received, the execution of the page code of the pre-rendered page and the obtaining of the page script from the page code comprise:

[0028] execute the page code of the pre-rendered page, and in the case that a script script exists at the front of the page code, obtain data reading code from the script script.

[0029] In an embodiment of the present application, before the page data obtaining request for the to-be-generated page is sent to the server, the method further comprises:

[0030] detect a current server load parameter;

[0031] When the server load parameters indicate server overload, the business type of the page to be generated is detected.

[0032] If the business type is a preset type, add an identifier indicating that server-side pre-rendering will not be used in the instruction for the page retrieval request for the page to be generated.

[0033] Thirdly, embodiments of the present invention provide a page rendering method applied to a page rendering system, the system including a client and a server, the method including:

[0034] The client sends a request to the server to retrieve page data for the page to be generated.

[0035] The server retrieves the code file of the page to be generated based on the page data retrieval request; it retrieves the first page layout required to be displayed on the page to be generated, updates the current page layout of the page to be generated based on the first page layout, and executes the event code whose main identifier is server-side execution to obtain the interface data of the first window in the page layout; based on the interface data and the first page layout, the page to be generated is pre-rendered to obtain a pre-rendered page; using data writing code, the data reading code, the interface data, and the main identifier of the event code are cached in the page script, injected into the pre-rendered page, and returned to the client. The code file includes event code for each window in the page, and each event code has a main identifier indicating whether the event code for that window is executed by the server or the client. The pre-rendered page is a static page, obtained by the server based on the page layout required to be displayed on the page to be generated and the interface data of the windows in the page layout. The data writing code and the data reading code are corresponding page script data processing codes.

[0036] Upon receiving a request response from the server, the client retrieves the pre-rendered page from the response, executes the page code of the pre-rendered page, and obtains the page script from the page code. It then uses the data reading code to read the interface data, fills the interface data into the first window of the pre-rendered page's layout, and renders the pre-rendered page. Next, it uses the data reading code to read the main identifier, executes the event code in the page code whose main identifier is the client-side execution parameter, and obtains the event data for the second window of the pre-rendered page's layout. Finally, it fills the event data into the second window of the pre-rendered page's layout to generate the target page, wherein the target page is an interactive page.

[0037] Fourthly, embodiments of the present invention also provide a page rendering apparatus, applied on a server, comprising:

[0038] The request receiving module is used to receive page data retrieval requests sent by the client for the page to be generated;

[0039] The page acquisition module is used to acquire the code file of the page to be generated based on the page data acquisition request. The page to be generated includes the event code of each window in the page. The event code has a subject identifier, which indicates that the event code of the window is executed by the server or the client.

[0040] The data acquisition module is used to acquire the first page layout to be displayed on the page to be generated, update the current page layout of the page to be generated based on the first page layout, and execute the event code identified by the main body as being executed by the server to obtain the interface data of the first window in the page layout.

[0041] The first page pre-rendering module is used to pre-render the page to be generated based on the interface data and the first page layout to obtain a pre-rendered page, wherein the pre-rendered page is a static page;

[0042] The page return module is used to use data writing code to cache the main identifier of the data reading code, the interface data, and the event code in the page script, inject it into the pre-rendered page, and return it to the client, so that the client can load the pre-rendered page based on the page script and use the data reading code to obtain the target page, wherein the target page is an interactive page, and the data writing code and the data reading code are corresponding page script data processing codes.

[0043] In one embodiment of the present invention, the apparatus further includes:

[0044] The execution detection module is used to detect whether the event code identified as being executed by the server has been successfully executed.

[0045] The status update module is used to update the status flag of the event code to "executed successfully" if the event code is executed successfully, and otherwise update the status flag of the event code to "executed unsuccessfully".

[0046] A state caching module is used to cache the state identifier of the event code in the page script.

[0047] Fifthly, embodiments of the present invention also provide a page rendering apparatus, applied to a client, comprising:

[0048] The request initiation module is used to send a request to the server to retrieve page data for the page to be generated;

[0049] The page acquisition module is used to acquire the pre-rendered page in the request response when the server returns a request response. The pre-rendered page is a static page and is obtained by the server based on the page layout to be displayed on the page to be generated and the interface data of the window in the page layout.

[0050] The script acquisition module is used to execute the page code of the pre-rendered page and acquire the page script from the page code. The page script includes data reading code, interface data generated by the server, and the main identifier of the event code. The main identifier indicates that the event code of each window of the pre-rendered page is executed by the server or the client.

[0051] The second page pre-rendering module is used to read the interface data using the data reading code, fill the interface data into the first window of the page layout of the pre-rendering page, and render the pre-rendering page.

[0052] The code execution module is used to read the main identifier using the data reading code, execute the event code in the page code whose main identifier is executed by the client, and obtain the event data of the second window in the page layout of the pre-rendered page;

[0053] The page generation module is used to fill the event data into the second window of the page layout of the pre-rendered page to generate the target page, wherein the target page is an interactive page.

[0054] In one embodiment of the present invention, the page generation module is specifically used for:

[0055] The data reading code reads the status identifier, executes the event code where the status identifier indicates failure, and obtains the interface data of the third window in the page layout of the pre-rendered page;

[0056] The event data is filled into the second window of the pre-rendered page layout, and the interface data of the third window is filled into the third window of the pre-rendered page layout to generate the target page.

[0057] In one embodiment of the present invention, the script acquisition module is specifically used for:

[0058] Execute the page code of the pre-rendered page, and if there is a script at the beginning of the page code, retrieve the data reading code from the script.

[0059] In one embodiment of the present invention, the apparatus further includes:

[0060] The stress detection module is used to detect the current server load parameters;

[0061] The business detection module is used to detect the business type of the page to be generated when the server load parameters indicate that the server is under overload.

[0062] The identifier addition module is used to add an identifier indicating that server-side pre-rendering is not used in the instruction for the page retrieval request for the page to be generated if the business type is a preset type.

[0063] Sixthly, embodiments of the present invention provide a page rendering apparatus applied to a page rendering system, the system including a client and a server, the apparatus including:

[0064] The request initiation module is used to send a request from the client to the server to retrieve page data for the page to be generated;

[0065] A pre-rendered page generation module is used to obtain the code file of the page to be generated by the server based on the page data acquisition request; obtain the first page layout to be displayed by the page to be generated; update the current page layout of the page to be generated based on the first page layout; and execute the event code with the main identifier indicating server execution to obtain the interface data of the first window in the page layout; pre-render the page to be generated based on the interface data and the first page layout to obtain the pre-rendered page; and use data writing code to cache the data reading code, the interface data, and the main identifier of the event code in the page script, inject them into the pre-rendered page, and return them to the client. The code file includes the event code of each window in the page, and the event code has a main identifier indicating whether the event code of that window is executed by the server or the client. The pre-rendered page is a static page, obtained by the server based on the page layout to be displayed by the page to be generated and the interface data of the windows in the page layout. The data writing code and the data reading code are corresponding page script data processing codes.

[0066] The target page generation module is used to: obtain a pre-rendered page from the request response received by the client from the server; execute the page code of the pre-rendered page; obtain the page script from the page code; read the interface data using the data reading code; fill the interface data into the first window of the page layout of the pre-rendered page; render the pre-rendered page; read the main identifier using the data reading code; execute the event code in the page code whose main identifier is the client-side execution, obtain the event data of the second window of the page layout of the pre-rendered page; fill the event data into the second window of the page layout of the pre-rendered page, and generate the target page, wherein the target page is an interactive page.

[0067] In another aspect of the present invention, an electronic device is also provided, comprising:

[0068] Memory, used to store computer programs;

[0069] The processor, when executing a program stored in memory, implements any of the page rendering methods described above.

[0070] In another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and the computer program, when executed by a processor, implements any of the page rendering methods described above.

[0071] In another aspect of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the page rendering methods described above.

[0072] The page rendering method provided in this embodiment of the invention involves the server receiving a page data acquisition request for a page to be generated, acquiring the code file of the page to be generated based on the page data acquisition request, the code file including event code for each window in the page, the event code having a subject identifier, the subject identifier indicating whether the event code of that window is executed by the server or the client; acquiring the first page layout to be displayed on the page to be generated, updating the current page layout of the page to be generated based on the first page layout, and executing the event code with the subject identifier indicating execution by the server to obtain the interface data of the first window in the page layout; pre-rendering the page to be generated based on the interface data and the first page layout to obtain a static pre-rendered page; caching the data reading code, interface data, and the subject identifier of the event code in the page script, injecting it into the pre-rendered page and returning it to the client, so that the client can quickly read the interface data and the event code that needs to be executed by the client based on the page script and using the data reading code.

[0073] The client can skip event code already executed by the server using the subject identifier, eliminating the need to re-execute all event code and perform secondary calculations on the interface data. It only needs to execute the event code identified as being executed by the client to obtain the interactive target page. Simultaneously, since the server only executes the code within the page identified as being executed by the server to obtain interface data when generating the pre-rendered page, without relying on the loading of UI framework code, routing, or other code components, the client also does not need to load the corresponding framework code when generating the target page. It can load the pre-rendered page and the interactive target page using only data reading code and event code. Compared to related technologies where the framework code is too large and difficult to load, causing delays in displaying the pre-rendered page on the client (especially when the client is running on a device with limited server resources), this invention eliminates the step of loading framework code, thus improving page rendering speed. Attached Figure Description

[0074] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.

[0075] Figure 1 A flowchart illustrating the first page rendering method provided in an embodiment of the present invention;

[0076] Figure 2 A flowchart illustrating the second page rendering method provided in an embodiment of the present invention;

[0077] Figure 3 A flowchart illustrating the third page rendering method provided in this embodiment of the invention;

[0078] Figure 4 This is one possible implementation of step S306 provided in the embodiments of the present invention;

[0079] Figure 5 A flowchart illustrating the fourth page rendering method provided in this embodiment of the invention;

[0080] Figure 6 A flowchart illustrating a page rendering process provided in an embodiment of the present invention;

[0081] Figure 7 A flowchart illustrating the fifth page rendering method provided in this embodiment of the invention;

[0082] Figure 8 This is a schematic diagram of the structure of a first page rendering device provided in an embodiment of the present invention;

[0083] Figure 9 This is a schematic diagram of the structure of a second page rendering device provided in an embodiment of the present invention;

[0084] Figure 10 This is a schematic diagram of the structure of the third page rendering device provided in an embodiment of the present invention;

[0085] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0086] The technical solutions of the present invention will now be described with reference to the accompanying drawings in the embodiments of the present invention.

[0087] Because server-side page rendering in related technologies relies on UI frameworks, in framework scenarios, when the client runs on a low-performance device, such as a device with an old browser kernel version or insufficient CPU (central processing unit) performance (e.g., a TV box), due to unintelligent browser kernel scheduling or manufacturer modifications to the system, many clients actually need to wait for component tools to finish loading before rendering the initial screen. Since framework scenarios require loading most component tools to execute page code, the loading of too many useless components slows down the initial screen display speed, leading to poor user experience issues such as blank screens and stuttering.

[0088] To address at least one of the aforementioned problems and improve page rendering speed, embodiments of the present invention provide a page rendering method, apparatus, electronic device, and storage medium.

[0089] The page rendering method provided in the embodiments of the present invention will be explained in detail below.

[0090] The page rendering method provided in this embodiment of the invention is applied to electronic devices equipped with a client, such as computers, mobile phones, smart TVs, etc.

[0091] See Figure 1 This invention provides a flowchart of a first page rendering method, applied to a server, including:

[0092] Step S101: Receive a page data retrieval request sent by the client for the page to be generated;

[0093] The server-side refers to the SSR server, which performs the pre-rendering task of the page. The page data retrieval request is sent by the client, which can be a browser, web media player, or various types of applications that require page loading. This page data retrieval request is a rendering request for the page to be generated, sent by the client to the gateway server; it is an HTML page request. The gateway server forwards the page data retrieval request to the SSR server, enabling the SSR server to pre-render the page to be generated.

[0094] In this process, the gateway server is only responsible for handling routing requests and scheduling traffic, while the SSR server is responsible for converting the front-end code and data into the page required by the user.

[0095] For example, when the gateway server receives a page data retrieval request, it checks whether the page address of the requested page includes an SSR identifier, such as isssr=1, indicating that server-side pre-rendering is required. If so, the gateway server forwards the page data retrieval request to the SSR server for pre-rendering; otherwise, the gateway server does not forward it to the SSR server but returns the relevant data for the client to render itself.

[0096] Step S102: Based on the page data acquisition request, obtain the code file of the page to be generated;

[0097] The code file includes event code for each window on the page. The event code has a subject identifier, which indicates whether the event code for that window is executed by the server or the client.

[0098] The server parses the page data retrieval request and obtains the page to be generated from the gateway server. The code file of the page to be generated is an HTML (Hypertext Markup Language) file, which is descriptive text composed of HTML commands. HTML commands can describe text, graphics, animations, sounds, tables, links, etc. For example, the code file of the page to be generated can be a single text file containing the logical code of multiple executable functions.

[0099] The code file for the generated page includes event code for each window on the page. A window represents a part of the page where content needs to be displayed; for example, the location for displaying a banner, an image, and text on a webpage corresponds to different windows. The event code includes code for obtaining the data required for the window to display, such as logic code for calling an API server to obtain the corresponding image data, as well as logic code for listening to events such as key presses and clicks.

[0100] Step S103: Obtain the first page layout to be displayed for the page to be generated, update the current page layout of the page to be generated based on the first page layout, and execute the event code identified by the main body as being executed by the server to obtain the interface data of the first window in the page layout;

[0101] When the server receives the page to be generated from the gateway server, the current page layout of the page to be generated is the original page template, which is a blank template without any adaptive window layout or displayed content. Based on the page generation requirements in the page data retrieval request, the server obtains the first page layout to be displayed on the page to be generated, updates the original page template with the first page layout, and obtains the page to be generated with an adaptive window layout (the first page layout).

[0102] The first page layout specifies which elements should be displayed in which locations on the page to be generated. For example, window 1 needs to display an image, window 2 needs to display text, etc., representing the arrangement of multiple windows on the page to be generated. Interface data, on the other hand, represents the corresponding data for each element on the current page. For example, the image data to be displayed in window 1, the text data to be displayed in window 2, etc. Without interface data and only the page layout, the page can only display static images and cannot respond to user actions. For instance, the page generation requirements can include instructions on the page layout, such as how many windows are needed to display images, how many windows to display descriptive text for the images, etc. The server can then plan the first page layout based on the page generation requirements.

[0103] The server retrieves the event code that identifies the main entity and executes it, then executes the event code to obtain the interface data for the first window. This interface data includes the specific content to be displayed in the first window, such as images and text descriptions. For example, when the page to be generated is related to a shopping platform, the interface data may include a product list and product information (on a shopping page), and may also include the user's information (on a personal center page). The server executes the event code to request page resources and interfaces from the resource and interface server, and obtains the interface data for the first window of the page to be generated based on the page resources and interface data returned by the server.

[0104] For example, the subject identifier can be set by the developers themselves, marking the time-consuming event code as to be executed on the server side. This allows the server to pre-execute to obtain the corresponding interface data, and the client does not need to execute it again. It only needs to execute the code with shorter execution time, thus accelerating the execution process of the time-consuming code and achieving the effect of server acceleration.

[0105] Step S104: Based on the interface data and the first page layout, pre-render the page to be generated to obtain the pre-rendered page;

[0106] The pre-rendered page is a static page;

[0107] The interface data is filled into the first window of the first page layout, and the page to be generated is pre-rendered to obtain the pre-rendered page. For example, the pre-rendered page is a static page without interactive functions, used only for displaying images, and is the first page rendered after the client receives it.

[0108] Step S105: Using data writing code, the main identifiers of data reading code, interface data, and event code are cached in the page script, injected into the pre-rendered page, and returned to the client, so that the client can load the pre-rendered page based on the page script using the data reading code to obtain the target page.

[0109] The target page is an interactive page, and the data writing code and the data reading code are corresponding page script data processing codes.

[0110] The data reading code is used to read the interface data and event code body identifiers stored in the page script. This allows the client to directly read the interface data generated by the server. Since the layout of the pre-rendered page has been updated to the first page layout, after the client reads the interface data, it can directly fill the interface data into the corresponding first window to obtain the pre-rendered page, which is then displayed. This is the first screen data displayed to the client. For example, the interface data may include the corresponding window identifier, allowing the client to quickly identify the location where the interface data needs to be filled in without recalculation.

[0111] The client can also quickly determine which event codes have been executed by the server and which need to be executed by the client through the subject identifier, and thus quickly execute the event codes whose subject identifier is set to be executed by the client. For example, the event codes whose subject identifier is set to be executed by the server can be logic code used to obtain interface data, and the event codes whose subject identifier is set to be executed by the client can be logic code used to listen for interactive events such as key presses and clicks on the page.

[0112] Once the client has executed the event code identified by the main body, the pre-rendered page can be transformed from a static screen used only for display into a dynamic screen that can be interacted with by the user, thus obtaining the target page.

[0113] As can be seen from the above, the page rendering method provided in this embodiment of the invention involves the server receiving a page data acquisition request for the page to be generated, acquiring the code file of the page to be generated based on the page data acquisition request, the code file including the event code of each window in the page, the event code having a subject identifier, the subject identifier indicating whether the event code of the window is executed by the server or the client; acquiring the first page layout to be displayed on the page to be generated, updating the current page layout of the page to be generated based on the first page layout, and executing the event code with the subject identifier indicating execution by the server to obtain the interface data of the first window in the page layout; pre-rendering the page to be generated based on the interface data and the first page layout to obtain a static pre-rendered page; caching the data reading code, interface data, and the subject identifier of the event code in the page script, injecting them into the pre-rendered page and returning them to the client, so that the client can quickly read the interface data and the event code that needs to be executed by the client based on the page script and the data reading code.

[0114] The client can skip event code already executed by the server using the subject identifier, eliminating the need to re-execute all event code and perform secondary calculations on the interface data. It only needs to execute the event code identified as being executed by the client to obtain the interactive target page. Simultaneously, since the server only executes the code within the page identified as being executed by the server to obtain interface data when generating the pre-rendered page, without relying on the loading of UI framework code, routing, or other code components, the client also does not need to load the corresponding framework code when generating the target page. It can load the pre-rendered page and the interactive target page using only data reading code and event code. Compared to related technologies where the framework code is too large and difficult to load, causing delays in displaying the pre-rendered page on the client (especially when the client is running on a device with limited server resources), this invention eliminates the step of loading framework code, thus improving page rendering speed.

[0115] In one embodiment of the present invention, such as Figure 2 As shown, the event code identifier also includes a status identifier, which indicates the current execution status of the event code. After obtaining the first page layout required to be displayed on the page to be generated in step S103, updating the current page layout of the page to be generated based on the first page layout, and executing the event code with the main identifier indicating server-side execution to obtain the interface data of the first window in the page layout, the process further includes:

[0116] Step S201: Detect whether the event code identified by the main body as being executed by the server has been successfully executed;

[0117] Step S202: If yes, update the status flag of the event code to "executed successfully"; otherwise, update the status flag of the event code to "executed unsuccessfully".

[0118] Step S203: Cache the status identifier of the event code in the page script.

[0119] The event code identifier also includes a status flag, which indicates the current execution status of the event code. When the event code is not executed, the status flag is "not executed". When the client receives the pre-rendered page, the status flag of all event codes whose main identifier is "executed by the client" is "not executed".

[0120] After the server finishes executing the event code identified as server-side execution, there may be a state of unsuccessful execution, such as not obtaining interface data or not obtaining complete interface data. In this case, the status of the event code will be updated to "unsuccessful execution". The execution status of the event code that has obtained complete interface data will be updated to "successful execution".

[0121] Status flags are cached in the page scripts so that the client can quickly determine the current execution status of all event codes and whether the client needs to execute them again. The client identifies event codes executed by the client as having an execution subject, and event codes executed by the server as having an execution subject but a status indicating unsuccessful execution.

[0122] As can be seen from the above, the page rendering method provided in this embodiment of the invention further includes a status flag for the event code to indicate the current execution status of the event code, so that the client can quickly determine the current execution status of all event codes and whether the client needs to execute them again. The client identifies the execution subject as the event code executed by the client, and the execution subject as the event code executed by the server but whose status is marked as unsuccessful, avoiding omissions in the execution of event codes within the page and ensuring the integrity of the target page.

[0123] In one embodiment of the present invention, the page script is a script, which is injected at the beginning of the page code of the pre-rendered page, and the data reading code is used to read interface data, the status identifier and the main identifier.

[0124] The data writing code (putServerData) is the page data processing function corresponding to the data reading code (getServerData). Both the data writing code and the event code are JavaScript code (JS for short, a programming language used for web page development). Script is a common script form in the JS language.

[0125] The pre-rendered page is an HTML page, essentially a text file containing code. A script is added to the very beginning of the pre-rendered page's code. When the client executes the pre-rendered page, execution starts from this beginning, executing the script first. Data reading code is then retrieved from the script, followed by cached API data, subject identifiers, and status identifiers to determine the execution status of the current event code. Only then are other necessary event codes executed within the page's code. If the client does not find an executable script in the pre-rendered page, it assumes the server did not pre-render, or pre-rendering failed, and the client restarts rendering the page itself.

[0126] In one example, common framework codebases typically include at least: UI frameworks (React (the core component library of the framework code), React DOM (the renderer of the framework code), routing systems, prefetching functionality, page interaction (hydration), image optimization components, font optimization components, etc. Even without specific business logic, this codebase still needs to be loaded. Excessive functionality introduces a large amount of JavaScript code, which cannot be completely removed even if the current page doesn't use it. However, on devices with lower browser kernel versions or insufficient CPU performance, such as TV boxes, most of the aforementioned framework components are not used during page generation. The large amount of framework code forces the client on the device to load all the code before it can apply the specific components of the current page, resulting in low page rendering efficiency and even a blank screen due to the inability to display the initial screen data.

[0127] The embodiments of the present invention implement data caching (using page scripts) for other SSR methods (such as methods for reading the main identifier of event code) without relying on other front-end UI frameworks, which greatly reduces the size of the JS code that needs to be executed, speeds up the execution of JS code, and greatly optimizes the first screen time on some low-performance devices.

[0128] Specifically, the code for writing and reading cached data in the script can also include the following SSR methods:

[0129] 1) putServerData() (the main body is identified as a server-side call): This is the code that writes data. The data is cached on the server side and written to the script.

[0130] 2) getServerData() (main body identified as client call): This is the data reading code, which retrieves cached data on the client side and obtains interface data from the script.

[0131] 3) SSRSuccess() / SSRFailed() (the main identifier is the server-side call): informs the SSR server when the requested interface data will return a result, whether the execution was successful or failed (used to detect and update the status identifier).

[0132] 4) ISSSRSuccess (main identifier is client call): used to read the status flag of the event code and determine whether the server has executed the event code successfully (whether the SSR server is successful). If it fails (execution is not completed), it needs to be downgraded to non-SSR rendering (i.e. the client executes the event code again and obtains the interface data itself).

[0133] 5) IS_SERVER_SIDE (Can be called by both server and client): Used to identify the subject of the event code and determine whether the current event code is executed on the client or server. Some code that does not need to be executed on the server, such as data statistics, can be skipped by the server, and similarly, the client can also skip code that does not need to be executed on the client.

[0134] As can be seen from the above, the page rendering method provided by the embodiments of the present invention achieves data caching of data reading code, main identifier and status identifier without relying on other front-end UI frameworks, which greatly reduces the size of JS, speeds up the execution of JS code, and greatly optimizes the first screen time on some low-performance devices.

[0135] See Figure 3 The present invention also provides a flowchart of a third page rendering method, applied to a client, including:

[0136] Step S301: Send a page data retrieval request for the page to be generated to the server;

[0137] Step S302: Upon receiving a request response from the server, obtain the pre-rendered page from the request response;

[0138] The pre-rendered page is a static page, which is obtained by the server based on the page layout to be displayed on the page to be generated, and the interface data of the window in the page layout.

[0139] Step S303: Execute the page code of the pre-rendered page and obtain the page script from the page code;

[0140] The page script includes data reading code, interface data generated by the server, and the main identifier of the event code. The main identifier indicates whether the event code of each window of the pre-rendered page is executed by the server or the client.

[0141] Step S304: Use data reading code to read interface data, fill the interface data into the first window of the page layout of the pre-rendered page, and render the pre-rendered page;

[0142] Step S305: Use the data reading code to read the main identifier, execute the event code in the page code whose main identifier is executed by the client, and obtain the event data of the second window in the page layout of the pre-rendered page;

[0143] Step S306: Fill the event data into the second window of the pre-rendered page layout to generate the target page.

[0144] The target page is an interactive page.

[0145] When the client receives a request response from the server, it determines the resource address corresponding to the page data retrieval request based on the resource address returned in the response, and retrieves the pre-rendered page from the response. For example, the client opens an H5 page and initiates an H5 page request; the server returns a corresponding HTML resource, which is the page code of the pre-rendered page, from which the client retrieves the page script.

[0146] If the server's response does not contain any page scripts, it is assumed that the server rendering failed or the server did not render the page, and the client will render the target page itself.

[0147] In one embodiment of the present invention, such as Figure 4 As shown, the page script also includes a status indicator for the event code, which indicates the current execution status of the event code. Step S306 above, which fills the event data into the second window of the pre-rendered page's page layout to generate the target page, includes:

[0148] Step S401: Use the data reading code to read the status identifier, execute the event code whose status identifier is not successfully executed, and obtain the interface data of the third window in the page layout of the pre-rendered page;

[0149] Step S402: Fill the event data into the second window of the pre-rendered page layout, fill the interface data of the third window into the third window of the pre-rendered page layout, and generate the target page.

[0150] In one embodiment of the present invention, upon receiving a pre-rendered page returned by the server, executing the page code of the pre-rendered page and obtaining the page script from the page code includes:

[0151] Execute the page code of the pre-rendered page, and if there is a script at the beginning of the page code, retrieve the data reading code from the script.

[0152] The client sends a page data retrieval request to the server. Upon receiving a pre-rendered page from the server, the client executes the pre-rendered page code from top to bottom. It retrieves the script from the top of the page code and extracts the data reading code from the script. The data reading code then reads the API data, the subject identifier, and the status identifier. The API data is filled into the first window of the pre-rendered page's layout. The client-side event code is executed, and the event data is obtained and filled into the second window of the pre-rendered page's layout.

[0153] The client uses the data reading code to read the status flag. If the status flag is "not executed successfully," it indicates that the server failed to execute the code. The client then executes the event code that failed to execute successfully, obtains the interface data for the third window in the pre-rendered page layout, fills the third window with the obtained data, and generates the target page.

[0154] As can be seen from the above, the page rendering method provided in this embodiment of the invention allows the client to first obtain data reading code through the page script when executing page code. This data reading code retrieves cached interface data, subject identifiers, and status identifiers within the script. Based on the subject identifier, it skips event code that has already been successfully executed by the server, eliminating the need to re-execute all event code and perform secondary calculations on the interface data. Only the event code identified as being executed by the client and the event code that was not successfully executed by the server needs to be executed to obtain the target page. This ensures the integrity of the target page and improves page generation efficiency. Simultaneously, since the server only executes the code identified as being executed by the server when generating the pre-rendered page to obtain interface data, without relying on the loading of UI framework code, routing, or other code components, the client does not need to load the corresponding framework code when generating the target page. This avoids the problem of excessively large framework code causing delays in displaying the pre-rendered page, thus improving page rendering speed. Data caching for other SSR methods (such as identifying the main identifier of event codes) is implemented (using scripts), which greatly reduces the size of JS and speeds up the execution of JS code. After reading the interface data generated by the server in the page script, it can be filled into the page to obtain a pre-rendered page for display, which greatly optimizes the first screen time on some low-performance devices.

[0155] In one embodiment of the present invention, such as Figure 5 As shown, before sending a request to the server to retrieve page data for the page to be generated, the method further includes:

[0156] Step S501: Detect the current server load parameters;

[0157] Step S502: When the server load parameters indicate that the server is under overload, detect the service type of the page to be generated;

[0158] Step S503: If the business type is a preset type, add an identifier indicating that server-side pre-rendering is not used to the instruction for the page retrieval request for the page to be generated.

[0159] Server load parameters include CPU, memory, and interface error status. If the load parameters indicate server overload, such as memory usage exceeding the memory usage threshold or CPU usage exceeding the usage threshold, it means that the current client is under heavy server pressure. In this case, some pages with low traffic or less important status do not need to request server rendering again, which would increase the burden. Then, the business type corresponding to the page request is determined. For example, if the most important business is the membership cashier, and other single-item purchases and special channel cashiers are non-important business types (pre-defined types), then when requesting these pages, server pre-rendering is not requested again. Instead, the relevant data can be requested from the gateway server for rendering. For example, if isssr=0 when making the request, it means that server pre-rendering is not required.

[0160] In one example, when the client receives the page returned by the server, it can also check whether the server has pre-rendered it. If it has pre-rendered it, it can directly render the interactive target page based on the pre-rendered page. If it detects that the server has not rendered it, it can request interface data from the resource and interface server and render the page itself based on the obtained interface data.

[0161] As can be seen from the above, the page rendering method provided in this embodiment of the invention can automatically shut down server pre-rendering requests corresponding to unimportant services when the server is overloaded, thereby reducing the server pressure on the device running on the client and making the page rendering method provided in this embodiment of the invention more suitable for devices with limited server resources.

[0162] like Figure 6 The diagram shown provides a flowchart example of a page rendering method.

[0163] Users open a page through a client. The client retrieves page resources from the SSR server. The SSR server requests page resources and interfaces from the resource and interface server. The resource and interface server returns page resources and interface data. The SSR server pre-renders the page based on the page resources and interface data, caches interface data using putserverdata, updates page modules, and returns the pre-rendered page. The client uses getserverdata to check whether the server (SSR server) has rendered the page. If so, it directly renders the interactive page based on the pre-rendered page. If not, it requests interface data from the resource and interface server. After obtaining the interface data, it renders the page based on the page resources and interface data.

[0164] See Figure 7 This invention also provides a flowchart of a fifth page rendering method, applied to a page rendering system, the system including a client and a server, the method including:

[0165] Step S701: Use the client to send a page data retrieval request for the page to be generated to the server;

[0166] Step S702: Using a server-side request based on page data acquisition, obtain the code file of the page to be generated; obtain the first page layout required to be displayed on the page to be generated; update the current page layout of the page to be generated based on the first page layout; and execute the event code whose main identifier is server-side execution to obtain the interface data of the first window in the page layout; based on the interface data and the first page layout, pre-render the page to be generated to obtain the pre-rendered page; using data writing code, cache the data reading code, the interface data, and the main identifier of the event code in the page script, inject them into the pre-rendered page, and return them to the client;

[0167] The code file includes event code for each window in the page. The event code has a subject identifier, which indicates whether the event code of the window is executed by the server or the client. The pre-rendered page is a static page, which is obtained by the server based on the page layout to be displayed on the page to be generated and the interface data of the windows in the page layout. The data writing code and the data reading code are corresponding page script data processing codes.

[0168] Step S703: Upon receiving a request response from the server, the client obtains the pre-rendered page from the request response, executes the page code of the pre-rendered page, and retrieves the page script from the page code; the client uses the data reading code to read the interface data, fills the interface data into the first window of the page layout of the pre-rendered page, and renders the pre-rendered page; the client uses the data reading code to read the main identifier, executes the event code in the page code whose main identifier is the client, and obtains the event data of the second window of the page layout of the pre-rendered page; the client fills the event data into the second window of the page layout of the pre-rendered page, and generates the target page.

[0169] The target page is an interactive page.

[0170] See Figure 8 The present invention also provides a schematic diagram of the structure of a first page rendering device, applied to a server, including:

[0171] The request receiving module 801 is used to receive page data retrieval requests sent by the client for the page to be generated;

[0172] The page acquisition module 802 is used to acquire the page to be generated based on the page data acquisition request. The page to be generated includes the event code of each window in the page. The event code has a subject identifier, and the subject identifier indicates that the event code of the window is executed by the server or the client.

[0173] The data acquisition module 803 is used to acquire the first page layout to be displayed on the page to be generated, update the current page layout of the page to be generated based on the first page layout, and execute the event code identified by the main body as being executed by the server to obtain the interface data of the first window in the page layout.

[0174] The first page pre-rendering module 804 is used to pre-render the page to be generated based on the interface data and the first page layout to obtain a pre-rendered page, wherein the pre-rendered page is a static page;

[0175] The page return module 805 is used to use data writing code to cache the main identifier of the data reading code, the interface data, and the event code in the page script, inject it into the pre-rendered page, and return it to the client, so that the client can load the pre-rendered page based on the page script using the data reading code to obtain the target page. The target page is an interactive page, and the data writing code and the data reading code are corresponding page script data processing codes.

[0176] As can be seen from the above, the page rendering apparatus provided in this embodiment of the invention involves the server receiving a page data acquisition request for a page to be generated, acquiring the code file of the page to be generated based on the page data acquisition request, the code file including event code for each window in the page, the event code having a subject identifier, the subject identifier indicating whether the event code of the window is executed by the server or the client; acquiring the first page layout to be displayed for the page to be generated, updating the current page layout of the page to be generated based on the first page layout, and executing the event code whose subject identifier is executed by the server to obtain the interface data of the first window in the page layout; pre-rendering the page to be generated based on the interface data and the first page layout to obtain a static pre-rendered page; caching the data reading code, interface data, and the subject identifier of the event code in the page script, injecting them into the pre-rendered page and returning them to the client, so that the client can quickly read the interface data and the event code that needs to be executed by the client based on the page script and the data reading code.

[0177] The client can skip event code already executed by the server using the subject identifier, eliminating the need to re-execute all event code and perform secondary calculations on the interface data. It only needs to execute the event code identified as being executed by the client to obtain the interactive target page. Simultaneously, since the server only executes the code within the page identified as being executed by the server to obtain interface data when generating the pre-rendered page, without relying on the loading of UI framework code, routing, or other code components, the client also does not need to load the corresponding framework code when generating the target page. It can load the pre-rendered page and the interactive target page using only data reading code and event code. Compared to related technologies where the framework code is too large and difficult to load, causing delays in displaying the pre-rendered page on the client (especially when the client is running on a device with limited server resources), this invention eliminates the step of loading framework code, thus improving page rendering speed.

[0178] In one embodiment of the present invention, the apparatus further includes:

[0179] The execution detection module is used to detect whether the event code identified as being executed by the server has been successfully executed.

[0180] The status update module is used to update the status flag of the event code to "executed successfully" if the event code is executed successfully, and otherwise update the status flag of the event code to "executed unsuccessfully".

[0181] A state caching module is used to cache the state identifier of the event code in the page script.

[0182] See Figure 9 The present invention also provides a schematic diagram of a second page rendering device, applied to a client, comprising:

[0183] The request initiation module 901 is used to send a request to the server to obtain page data for the page to be generated;

[0184] The page acquisition module 902 is used to acquire the pre-rendered page in the request response when the server returns a request response, wherein the pre-rendered page is a static page, and the pre-rendered page is obtained by the server based on the page layout to be displayed on the page to be generated, and the interface data of the window in the page layout.

[0185] The script acquisition module 903 is used to execute the page code of the pre-rendered page and acquire the page script from the page code. The page script includes data reading code, interface data generated by the server, and the main identifier of the event code. The main identifier indicates that the event code of each window of the pre-rendered page is executed by the server or the client.

[0186] The second page pre-rendering module 904 is used to read the interface data using the data reading code, fill the interface data into the first window of the page layout of the pre-rendered page, and render the pre-rendered page.

[0187] The code execution module 905 is used to read the main identifier using the data reading code, execute the event code in the page code whose main identifier is executed by the client, and obtain the event data of the second window in the page layout of the pre-rendered page;

[0188] The page generation module 906 is used to fill the event data into the second window of the page layout of the pre-rendered page to generate the target page, wherein the target page is an interactive page.

[0189] In one embodiment of the present invention, the page generation module 906 is specifically used for:

[0190] The data reading code reads the status identifier, executes the event code where the status identifier indicates failure, and obtains the interface data of the third window in the page layout of the pre-rendered page;

[0191] The event data is filled into the second window of the pre-rendered page layout, and the interface data of the third window is filled into the third window of the pre-rendered page layout to generate the target page.

[0192] In one embodiment of the present invention, the script acquisition module 903 is specifically used for:

[0193] Execute the page code of the pre-rendered page, and if there is a script at the beginning of the page code, retrieve the data reading code from the script.

[0194] In one embodiment of the present invention, the apparatus further includes:

[0195] The stress detection module is used to detect the current server load parameters;

[0196] The business detection module is used to detect the business type of the page to be generated when the server load parameters indicate that the server is under overload.

[0197] The identifier addition module is used to add an identifier indicating that server-side pre-rendering is not used in the instruction for the page retrieval request for the page to be generated if the business type is a preset type.

[0198] See Figure 10 This invention provides a schematic diagram of a page rendering device, applied to a page rendering system. The system includes a client and a server, and the device includes:

[0199] The request initiation module 1001 is used to send a request to the server for obtaining page data for the page to be generated using the client.

[0200] The pre-rendered page generation module 1002 is used to obtain the code file of the page to be generated by the server based on the page data acquisition request; obtain the first page layout to be displayed by the page to be generated; update the current page layout of the page to be generated based on the first page layout; and execute the event code with the main identifier indicating that it is executed by the server to obtain the interface data of the first window in the page layout; pre-render the page to be generated based on the interface data and the first page layout to obtain the pre-rendered page; and use data writing code to cache the data reading code, the interface data, and the main identifier of the event code in the page script, inject them into the pre-rendered page, and return them to the client. The code file includes the event code of each window in the page, and the event code has a main identifier indicating that the event code of that window is executed by the server or the client. The pre-rendered page is a static page, obtained by the server based on the page layout to be displayed by the page to be generated and the interface data of the windows in the page layout. The data writing code and the data reading code are corresponding page script data processing codes.

[0201] The target page generation module 1003 is used to: obtain a pre-rendered page from a request response received by the client from the server; execute the page code of the pre-rendered page; obtain page scripts from the page code; read interface data using the data reading code; fill the interface data into the first window of the page layout of the pre-rendered page; render the pre-rendered page; read the main identifier using the data reading code; execute the event code in the page code whose main identifier is the client-side execution, obtain event data for the second window of the page layout of the pre-rendered page; fill the event data into the second window of the page layout of the pre-rendered page, and generate a target page, wherein the target page is an interactive page.

[0202] This invention also provides an electronic device, such as... Figure 11 As shown, it includes a processor 1101, a communication interface 1102, a memory 1103, and a communication bus 1104. The processor 1101, communication interface 1102, and memory 1103 communicate with each other via the communication bus 1104.

[0203] Memory 1103 is used to store computer programs;

[0204] The processor 1101 is used to implement any of the page rendering methods described above when executing the program stored in the memory 1103.

[0205] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0206] The communication interface is used for communication between the aforementioned terminal and other devices.

[0207] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0208] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0209] In another embodiment of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements any of the page rendering methods described in the above embodiments.

[0210] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the page rendering methods described in the above embodiments.

[0211] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0212] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0213] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the apparatus embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0214] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A page rendering method, characterized in that, Applied to the server side, including: Receive page data retrieval requests sent by the client for the page to be generated; Based on the page data acquisition request, the code file of the page to be generated is obtained. The code file includes the event code of each window in the page. The event code has a subject identifier, which indicates whether the event code of the window is executed by the server or the client. Obtain the first page layout to be displayed for the page to be generated, update the current page layout of the page to be generated based on the first page layout, and execute the event code identified by the main body as being executed on the server side to obtain the interface data of the first window in the page layout; Based on the interface data and the first page layout, the page to be generated is pre-rendered to obtain a pre-rendered page, wherein the pre-rendered page is a static page; The main identifier of the data reading code, the interface data, and the event code is cached in the page script using the data writing code, injected into the pre-rendered page, and returned to the client. This allows the client to load the pre-rendered page based on the page script using the data reading code to obtain the target page. The target page is an interactive page, and the data writing code and the data reading code are corresponding page script data processing codes.

2. The method according to claim 1, characterized in that, The event code identifier also includes a status identifier, which indicates the current execution status of the event code. After obtaining the first page layout required to be displayed on the page to be generated, updating the current page layout of the page to be generated based on the first page layout, and executing the event code whose main identifier is server-side execution to obtain the interface data of the first window in the page layout, the process further includes: Check whether the event code identified by the main entity as being executed by the server was successfully executed; If yes, update the status flag of the event code to "executed successfully"; otherwise, update the status flag of the event code to "executed unsuccessfully". The status identifier of the event code is cached in the page script.

3. The method according to claim 2, characterized in that, The page script is a script, which is injected at the beginning of the page code of the pre-rendered page. The data reading code is used to read interface data, the status identifier, and the main identifier.

4. A page rendering method, characterized in that, Applied to the client side, including: Send a request to the server to retrieve page data for the page to be generated; Upon receiving a request response from the server, the server retrieves the pre-rendered page from the request response. The pre-rendered page is a static page, which is obtained by the server based on the page layout required to be displayed on the page to be generated, and the interface data of the windows in the page layout. Execute the page code of the pre-rendered page, and obtain the page script from the page code. The page script includes data reading code, interface data generated by the server, and the main identifier of the event code. The main identifier indicates that the event code of each window of the pre-rendered page is executed by the server or the client. The data reading code reads the interface data, fills the interface data into the first window of the pre-rendered page layout, and renders the pre-rendered page. The data reading code is used to read the main identifier, and the event code in the page code whose main identifier is executed by the client is executed, to obtain the event data of the second window in the page layout of the pre-rendered page; The event data is filled into the second window of the pre-rendered page layout to generate the target page, wherein the target page is an interactive page.

5. The method according to claim 4, characterized in that, The page script also includes a status indicator for the event code, which indicates the current execution state of the event code. The step of filling the event data into the second window of the pre-rendered page's page layout to generate the target page includes: The data reading code reads the status identifier, executes the event code where the status identifier indicates failure, and obtains the interface data of the third window in the page layout of the pre-rendered page; The event data is filled into the second window of the pre-rendered page layout, and the interface data of the third window is filled into the third window of the pre-rendered page layout to generate the target page.

6. The method according to claim 4, characterized in that, Upon receiving a pre-rendered page returned by the server, executing the page code of the pre-rendered page and obtaining the page script from the page code includes: Execute the page code of the pre-rendered page, and if there is a script at the beginning of the page code, retrieve the data reading code from the script.

7. The method according to claim 4, characterized in that, Before sending a request to the server to retrieve page data for the page to be generated, the method further includes: Detect current server load parameters; When the server load parameters indicate server overload, the business type of the page to be generated is detected. If the business type is a preset type, add an identifier indicating that server-side pre-rendering will not be used in the instruction for the page retrieval request for the page to be generated.

8. A page rendering method, characterized in that, Applied to a page rendering system, the system including a client and a server, the method includes: The client sends a request to the server to retrieve page data for the page to be generated. The server retrieves the code file of the page to be generated based on the page data retrieval request; it retrieves the first page layout to be displayed on the page to be generated, updates the current page layout of the page to be generated based on the first page layout, and executes event code with the main identifier indicating server execution to obtain interface data of the first window in the page layout; based on the interface data and the first page layout, it pre-renders the page to be generated to obtain a pre-rendered page; using data writing code, it caches the data reading code, the interface data, and the main identifier of the event code in the page script, injects them into the pre-rendered page, and returns them to the client. The code file includes event code for each window in the page, and each event code has a main identifier indicating whether the event code for that window is executed by the server or the client. The pre-rendered page is a static page, obtained by the server based on the page layout to be displayed on the page to be generated and the interface data of the windows in the page layout. The data writing code and the data reading code are corresponding page script data processing codes. Upon receiving a request response from the server, the client retrieves the pre-rendered page from the response, executes the page code of the pre-rendered page, and obtains the page script from the page code. It then uses the data reading code to read the interface data, fills the interface data into the first window of the pre-rendered page's layout, and renders the pre-rendered page. Next, it uses the data reading code to read the main identifier, executes the event code in the page code whose main identifier is the client-side execution parameter, and obtains the event data for the second window of the pre-rendered page's layout. Finally, it fills the event data into the second window of the pre-rendered page's layout to generate the target page, wherein the target page is an interactive page.

9. A page rendering device, characterized in that, Applied to the server side, including: The request receiving module is used to receive page data retrieval requests sent by the client for the page to be generated; The page acquisition module is used to acquire the code file of the page to be generated based on the page data acquisition request. The page to be generated includes the event code of each window in the page. The event code has a subject identifier, which indicates that the event code of the window is executed by the server or the client. The data acquisition module is used to acquire the first page layout to be displayed on the page to be generated, update the current page layout of the page to be generated based on the first page layout, and execute the event code identified by the main body as being executed by the server to obtain the interface data of the first window in the page layout. The first page pre-rendering module is used to pre-render the page to be generated based on the interface data and the first page layout to obtain a pre-rendered page, wherein the pre-rendered page is a static page; The page return module is used to use data writing code to cache the main identifier of the data reading code, the interface data, and the event code in the page script, inject it into the pre-rendered page, and return it to the client, so that the client can load the pre-rendered page based on the page script and use the data reading code to obtain the target page, wherein the target page is an interactive page, and the data writing code and the data reading code are corresponding page script data processing codes.

10. A page rendering apparatus, characterized in that, Applied to the client side, including: The request initiation module is used to send a request to the server to retrieve page data for the page to be generated; The script acquisition module is used to acquire the pre-rendered page in the request response when the server returns a request response. The pre-rendered page is a static page and is obtained by the server based on the page layout to be displayed on the page to be generated and the interface data of the window in the page layout. Execute the page code of the pre-rendered page, and obtain the page script from the page code. The page script includes data reading code, interface data generated by the server, and the main identifier of the event code. The main identifier indicates that the event code of each window of the pre-rendered page is executed by the server or the client. The second page pre-rendering module is used to read the interface data using the data reading code, fill the interface data into the first window of the page layout of the pre-rendering page, and render the pre-rendering page. The code execution module is used to read the main identifier using the data reading code, execute the event code in the page code whose main identifier is executed by the client, and obtain the event data of the second window in the page layout of the pre-rendered page; The page generation module is used to fill the event data into the second window of the page layout of the pre-rendered page to generate the target page, wherein the target page is an interactive page.

11. A page rendering apparatus, applied to a page rendering system, the system comprising a client and a server, the apparatus comprising: The request initiation module is used to send a request from the client to the server to retrieve page data for the page to be generated; The pre-rendered page generation module is used to obtain the code file of the page to be generated by the server based on the page data acquisition request. Obtain the first page layout to be displayed for the page to be generated, update the current page layout of the page to be generated based on the first page layout, and execute the event code with the main identifier being executed by the server to obtain the interface data of the first window in the page layout; Based on the interface data and the first page layout, the page to be generated is pre-rendered to obtain a pre-rendered page; using data writing code, the data reading code, the interface data, and the main identifier of the event code are cached in the page script, injected into the pre-rendered page, and returned to the client. The code file includes event code for each window in the page, and each event code has a main identifier indicating whether the event code for that window is executed by the server or the client. The pre-rendered page is a static page, obtained by the server based on the page layout required to be displayed on the page to be generated and the interface data of the windows in the page layout. The data writing code and the data reading code are corresponding page script data processing codes. The target page generation module is used to: obtain a pre-rendered page from the request response received by the client from the server; execute the page code of the pre-rendered page; obtain the page script from the page code; read the interface data using the data reading code; fill the interface data into the first window of the page layout of the pre-rendered page; render the pre-rendered page; read the main identifier using the data reading code; execute the event code in the page code whose main identifier is the client-side execution, obtain the event data of the second window of the page layout of the pre-rendered page; fill the event data into the second window of the page layout of the pre-rendered page, and generate the target page, wherein the target page is an interactive page.

12. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the method described in any one of claims 1-8.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1-8.