WO2025201412A1 - 页面渲染方法、设备及存储介质 - Google Patents
页面渲染方法、设备及存储介质Info
- Publication number
- WO2025201412A1 WO2025201412A1 PCT/CN2025/085051 CN2025085051W WO2025201412A1 WO 2025201412 A1 WO2025201412 A1 WO 2025201412A1 CN 2025085051 W CN2025085051 W CN 2025085051W WO 2025201412 A1 WO2025201412 A1 WO 2025201412A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- page
- data block
- rendering
- streaming
- data
- Prior art date
- Legal status (The legal status 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 status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/957—Browsing optimisation, e.g. caching or content distillation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/958—Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
Definitions
- the embodiments of the present disclosure relate to a page rendering method, device, and storage medium.
- each chunk requires a specific API (usually determined by the framework).
- This API can only handle chunks returned once, not multiple chunks. Therefore, streaming rendering typically requires multiple APIs. However, in some business scenarios, only one API is provided. If this API is a streaming API, meaning it returns multiple chunks, streaming rendering is unsupported.
- Embodiments of the present disclosure provide a page rendering method, device, and storage medium.
- each calling function is used to call a data block received by the streaming interface
- an embodiment of the present disclosure provides a page rendering device, including:
- a receiving unit configured to asynchronously obtain multiple data blocks of the target page through a streaming interface
- a conversion unit configured to generate a plurality of calling functions for the streaming interface, wherein each calling function is configured to call a data block received by the streaming interface;
- a rendering unit is used to render the target page using a streaming rendering method.
- the multiple calling functions are respectively called through a preset data acquisition interface to obtain corresponding data blocks, and rendering is performed according to each data block to obtain a streaming rendering result, and the streaming rendering result is returned to the terminal device so that the terminal device displays the target page according to the streaming rendering result.
- an embodiment of the present disclosure provides an electronic device, including: at least one processor and a memory;
- an embodiment of the present disclosure provides a computer-readable storage medium, in which computer-executable instructions are stored.
- a processor executes the computer-executable instructions, the page rendering method described in the first aspect and various possible designs of the first aspect is implemented.
- an embodiment of the present disclosure provides a computer program product, comprising computer-executable instructions.
- a processor executes the computer-executable instructions, the page rendering method described in the first aspect and various possible designs of the first aspect is implemented.
- FIG1 is a diagram illustrating an example scenario of a page rendering method provided by an embodiment of the present disclosure
- FIG2 is a schematic diagram of a page rendering method according to an embodiment of the present disclosure.
- FIG3 is a flow chart of a page rendering method provided by another embodiment of the present disclosure.
- FIG5 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure.
- the present disclosure provides a page rendering method, in the hope of realizing the combination of streaming interface and streaming rendering in the back-end rendering process. Specifically, by receiving an access request for a target page sent by a terminal device, and asynchronously obtaining multiple data blocks of the target page through a streaming interface; generating multiple calling functions for the streaming interface, wherein each calling function is used to call a data block received by the streaming interface; rendering the target page using streaming rendering, calling the multiple calling functions respectively through a preset data acquisition interface during the rendering process to obtain corresponding data blocks, and rendering is performed respectively according to each data block to obtain a streaming rendering result, and returning the streaming rendering result to the terminal device, so that the terminal device displays the target page according to the streaming rendering result.
- multiple data blocks of the target page can be obtained through a streaming interface, and multiple data blocks obtained by the streaming interface can be called during the streaming rendering process by calling a function, so that there is no need to use multiple interfaces to request data blocks during the streaming rendering stage, thereby realizing the combination of streaming interface and streaming rendering, reducing the number of interfaces and interface time consumption, and improving the rendering speed of the target page, reducing the waiting time of the terminal device user, and improving the user's experience of browsing the target page.
- the application scenario of the page rendering method of the embodiment of the present disclosure is shown in Figure 1, including a terminal device and a server, wherein the terminal device may send an access request for the target page to the server when it needs to access the target page.
- the server may asynchronously obtain multiple data blocks of the target page through a streaming interface; in addition, the server may generate multiple calling functions for the streaming interface, wherein each calling function is used to call a data block received by the streaming interface; the target page is rendered using a streaming rendering method, and during the rendering process, multiple calling functions are called separately through a preset data acquisition interface to obtain corresponding data blocks, and rendering is performed separately according to each data block to obtain a streaming rendering result, and the streaming rendering result is returned to the terminal device, so that the terminal device displays the target page according to the streaming rendering result.
- S201 Receive an access request for a target page sent by a terminal device, and asynchronously obtain multiple data blocks of the target page through a streaming interface.
- a terminal device when a terminal device needs to access a target page, it can send an access request for the target page to the server.
- the server can divide the target page into multiple data chunks and use a streaming interface to obtain the multiple data chunks of the target page, such as obtaining the multiple data chunks of the target page from a database.
- the use of a streaming interface is due to business needs, that is, only one interface can be provided for the server to obtain the data of the target page.
- the target page is divided into multiple data chunks, so the streaming interface is used.
- this embodiment does not limit the specific method for the server to divide the data chunks of the target page.
- Rendering is performed on each data block to obtain streaming hypertext markup language HTML data, and the streaming HTML data is used as the streaming rendering result.
- the page context information and the number of data blocks of the target page are taken as input, and a preset converter module is called to generate the multiple calling modules.
- the plurality of data blocks include a first data block, a second data block, and a third data block;
- an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart.
- the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502.
- the processing device 501 When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
- the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two.
- a computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above.
- a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above.
- a computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
- the program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
- the computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
- the computer-readable medium carries one or more programs.
- the electronic device executes the method shown in the above embodiment.
- Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages.
- the program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server.
- the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
- LAN local area network
- WAN wide area network
- Internet service provider e.g., AT&T, MCI, Sprint, EarthLink, MSN, GTE, etc.
- each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function.
- the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved.
- each box in the block diagram and/or flowchart, and the combination of the boxes in the block diagram and/or flowchart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
- exemplary types of hardware logic components include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
- FPGAs field programmable gate arrays
- ASICs application specific integrated circuits
- ASSPs application specific standard products
- SOCs systems on chip
- CPLDs complex programmable logic devices
- a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment.
- a machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium.
- a machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing.
- a more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
- RAM random access memory
- ROM read-only memory
- EPROM or flash memory erasable programmable read-only memory
- CD-ROM portable compact disk read-only memory
- CD-ROM compact disk read-only memory
- magnetic storage device or any suitable combination of the foregoing.
- each calling function is used to call a data block received by the streaming interface
- Rendering is performed on each data block to obtain streaming hypertext markup language HTML data, and the streaming HTML data is used as the streaming rendering result.
- generating multiple calling functions for the streaming interface includes:
- the multiple calling functions are respectively called through a preset data acquisition interface, and the page context information is respectively input into the multiple calling functions, and corresponding data blocks output by the multiple calling functions are respectively acquired.
- generating the multiple calling functions according to the page context information and the number of data blocks of the target page includes:
- the page context information and the number of data blocks of the target page are taken as input, and a preset converter module is called to generate the multiple calling modules.
- the plurality of data blocks include a first data block, a second data block, and a third data block;
- the first data block is a data block corresponding to the predicted page content of the target page, and the predicted page content is the page content obtained by the prediction model according to the access request;
- the second data block is a data block used to characterize the predictive validity of the predicted page content;
- the third data block is a data block corresponding to the actual page content of the target page, and the actual page content is the page content obtained by the search engine according to the access request, and whether the predicted page content is included in the third data block is determined based on the predictive validity of the predicted page content.
- calling the plurality of calling functions respectively through a preset data acquisition interface to acquire corresponding data blocks during the rendering process, and rendering according to each data block respectively includes:
- the calling function corresponding to the first data block is called through the preset data acquisition interface to obtain the first data block, and the target page is partially rendered according to the first data block to preferentially display the predicted page content in the target page; then the calling function corresponding to the third data block is called through the preset data acquisition interface to obtain the third data block, and the remaining part of the target page is rendered according to the third data block.
- the method further includes:
- the calling function corresponding to the third data block is directly called through the preset data acquisition interface to obtain the third data block, and the entire page of the target page is rendered according to the third data block.
- a page rendering device including:
- a request unit configured to receive an access request for a target page sent by a terminal device
- a receiving unit configured to asynchronously obtain multiple data blocks of the target page through a streaming interface
- Rendering is performed on each data block to obtain streaming hypertext markup language HTML data, and the streaming HTML data is used as the streaming rendering result.
- the conversion unit when generating multiple call functions for the stream interface, is configured to:
- the page context information of the target page is obtained, and the multiple calling functions are generated according to the page context information and the number of data blocks of the target page, wherein the input of any calling function is the page context information and the output is the corresponding data block.
- the rendering unit when the rendering unit calls the multiple calling functions respectively through the preset data acquisition interface to obtain corresponding data blocks during the rendering process, it is configured to:
- the multiple calling functions are respectively called through a preset data acquisition interface, and the page context information is respectively input into the multiple calling functions, and corresponding data blocks output by the multiple calling functions are respectively acquired.
- the conversion unit when the conversion unit generates the multiple calling functions according to the page context information and the number of data blocks of the target page, it is configured to:
- the page context information and the number of data blocks of the target page are taken as input, and a preset converter module is called to generate the multiple calling modules.
- the plurality of data blocks include a first data block, a second data block, and a third data block;
- the first data block is a data block corresponding to the predicted page content of the target page, and the predicted page content is the page content obtained by the prediction model according to the access request;
- the second data block is a data block used to characterize the predictive validity of the predicted page content;
- the third data block is a data block corresponding to the actual page content of the target page, and the actual page content is the page content obtained by the search engine according to the access request, and whether the predicted page content is included in the third data block is determined based on the predictive validity of the predicted page content.
- the rendering unit is configured to:
- a calling function corresponding to the second data block is preferentially called through a preset data acquisition interface to obtain the second data block;
- the rendering unit is further configured to:
- the calling function corresponding to the third data block is directly called through the preset data acquisition interface to obtain the third data block, and the entire page of the target page is rendered according to the third data block.
- an electronic device comprising: at least one processor and a memory;
- the at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the page rendering method described in the first aspect and various possible designs of the first aspect.
- a computer-readable storage medium stores computer-executable instructions.
- the page rendering method described in the first aspect and various possible designs of the first aspect is implemented.
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Between Computers (AREA)
Abstract
本公开实施例提供一种页面渲染方法、设备及存储介质,通过服务端接收终端设备对目标页面的访问请求,并通过一个流式接口异步获取目标页面的多个数据块;针对流式接口生成多个调用函数,每个调用函数用于调用一个数据块;采用流式渲染方式进行渲染,在渲染过程中分别调用多个调用函数以获取对应的数据块,并进行渲染得到流式渲染结果,将流式渲染结果返回给终端设备。服务端通过一个流式接口从获取目标页面的多个数据块,并通过调用函数的方式在流式渲染过程中调用流式接口获取的多个数据块,使得流式渲染阶段无需采用多个接口请求数据块,实现了流式接口与流式渲染的结合,提高了目标页面的渲染速度,提升用户浏览目标页面的体验。
Description
本申请要求于2024年03月29日递交的中国专利申请第202410382056.1号的优先权,在此全文引用上述中国专利申请公开的内容以作为本申请的一部分。
本公开实施例涉及一种页面渲染方法、设备及存储介质。
在对前端页面的性能优化中,通常在后端渲染时会对页面采用流式渲染,也即服务端以流(chunk-by-chunk)的形式分段传输HTML数据进行渲染,而无需等到整个页面渲染完再发送给终端设备,这可以大大提高页面渲染性能,让终端设备用户更早地看到页面内容。
而服务端在获取页面的数据块(chunk)时,每个数据块都需要一个特定接口(通常由框架决定)来获取,特定接口往往只能处理一次性返回的数据块,而不能处理多次返回的数据块,因此流式渲染通常需要多个接口。但是在某些业务场景中只提供一个接口,若该接口为流式接口,也即该接口多次返回数据块,则无法支持流式渲染。
本公开实施例提供一种页面渲染方法、设备及存储介质。
第一方面,本公开实施例提供一种页面渲染方法,应用于服务端,所述方法包括:
接收终端设备发送的对目标页面的访问请求,并通过一个流式接口异步获取所述目标页面的多个数据块;
针对所述流式接口,生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块;
对所述目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将所述流式渲染结果返回给所述终端设备,以使所述终端设备根据所述流式渲染结果显示所述目标页面。
第二方面,本公开实施例提供一种页面渲染设备,包括:
请求单元,用于接收终端设备发送的对目标页面的访问请求;
接收单元,用于通过一个流式接口异步获取所述目标页面的多个数据块;
转换单元,用于针对所述流式接口,生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块;
渲染单元,用于对所述目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将所述流式渲染结果返回给所述终端设备,以使所述终端设备根据所述流式渲染结果显示所述目标页面。
第三方面,本公开实施例提供一种电子设备,包括:至少一个处理器和存储器;
所述存储器存储计算机执行指令;
所述至少一个处理器执行所述存储器存储的计算机执行指令,使得所述至少一个处理器执行如上第一方面以及第一方面各种可能的设计所述的页面渲染方法。
第四方面,本公开实施例提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,当处理器执行所述计算机执行指令时,实现如上第一方面以及第一方面各种可能的设计所述的页面渲染方法。
第五方面,本公开实施例提供一种计算机程序产品,包括计算机执行指令,当处理器执行所述计算机执行指令时,实现如上第一方面以及第一方面各种可能的设计所述的页面渲染方法。
为了更清楚地说明本公开实施例中的技术方案,下面将对实施例中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本公开的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本公开一实施例提供的页面渲染方法的场景示例图;
图2为本公开一实施例提供的页面渲染方法流程示意图;
图3为本公开另一实施例提供的页面渲染方法流程示意图;
图4为本公开一实施例提供的页面渲染设备的结构框图;
图5为本公开一实施例提供的电子设备的硬件结构示意图。
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本公开一部分实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。
在对前端页面的性能优化中,通常在后端渲染时会对页面采用流式渲染,也即服务端以流(chunk-by-chunk)的形式分段传输HTML数据进行渲染,而无需等到整个页面渲染完再发送给终端设备,这可以大大提高页面渲染性能,让终端设备用户更早地看到页面内容。
而服务端在获取页面的数据块(chunk)时,每个数据块都需要一个特定接口API(通常由框架决定)来获取,特定接口往往只能处理一次性返回的数据块,而不能处理多次返回的数据块,因此流式渲染通常需要多个接口。例如在流式渲染中以组件为单位,在每个组件中通过一个特定API来获取数据。
但是在某些业务场景中只提供一个接口,若该接口为流式接口,也即该接口多次返回数据块,则无法支持流式渲染。
为了解决上述技术问题,本公开提供一种页面渲染方法,以期望在后端渲染过程中实现流式接口与流式渲染的结合,具体的,通过接收终端设备发送的对目标页面的访问请求,并通过一个流式接口异步获取所述目标页面的多个数据块;针对所述流式接口,生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块;对所述目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将所述流式渲染结果返回给所述终端设备,以使所述终端设备根据所述流式渲染结果显示所述目标页面。本公开实施例在服务端接收到终端设备对目标页面的访问请求后,可通过一个流式接口获取目标页面的多个数据块,并通过调用函数的方式在流式渲染过程中调用流式接口获取的多个数据块,使得流式渲染阶段无需采用多个接口请求数据块,实现了流式接口与流式渲染的结合,减少接口数量和接口耗时,并且提高了目标页面的渲染速度,减少终端设备用户的等待时长,提升用户浏览目标页面的体验。
本公开实施例的页面渲染方法的应用场景如图1所示,包括终端设备和服务端,其中终端设备在需要访问目标页面时,可向服务端发送对目标页面的访问请求,服务端接收到访问请求后,可通过一个流式接口异步获取目标页面的多个数据块;此外,服务端可针对流式接口生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块;对目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将流式渲染结果返回给终端设备,以使终端设备根据所述流式渲染结果显示所述目标页面。
需要说明的是,本公开所涉及的用户信息(包括但不限于用户设备信息、用户个人信息等)和数据(包括但不限于用于分析的数据、存储的数据、展示的数据等),均为经用户授权或者经过各方充分授权的信息和数据,并且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准,并提供有相应的操作入口,供用户选择授权或者拒绝。
下面将结合具体实施例对本公开的页面渲染方法进行详细介绍。
参考图2,图2为本公开一实施例提供的页面渲染方法流程示意图。本实施例的方法可以应用在服务端中,该页面渲染方法包括:
S201、接收终端设备发送的对目标页面的访问请求,并通过一个流式接口异步获取所述目标页面的多个数据块。
在本实施例中,在终端设备需要访问目标页面时,可以向服务端发送对目标页面的访问请求,而为了提高终端设备对目标页面的渲染速度,让终端设备的用户能够尽早看到目标页面中的页面内容,服务端可将目标页面划分为多个数据块(chunk),并且采用一个流式接口获取目标页面的多个数据块,例如从数据库获取目标页面的多个数据块,其中采用一个流式接口为业务需要,也即只能提供一个接口供服务端获取目标页面的数据,而目标页面被划分为多个数据块,因此采用流式接口。此外本实施例中并不限定服务端对目标页面具体如何划分数据块。
其中,由于目标页面划分为多个数据块,且采用一个流式接口接收,而后续可采用流式渲染,因此并不需要等待每一个数据块都返回后再执行后续步骤,也即本实施例中可通过一个流式接口异步接收服务端返回的目标页面的多个数据块。
S202、针对所述流式接口,生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块。
在本实施例中,在接收终端设备发送的对目标页面的访问请求后,服务端可以针对于流式接口生成多个调用函数,调用函数用于调用流式接口接收到的一个数据块,以调用函数模拟流式渲染时所需的多个接口,每个接口用于获取目标页面的一个数据块,也即调用函数的数量可以等于目标页面的数据块的数量。需要说明的是,生成调用函数可以是在接收终端设备发送的对目标页面的访问请求后就开始执行,而无需等待接收到服务端返回的目标页面的多个数据块,也即S202并不限于在S201之后执行,也可以在S201接收到终端设备发送的对目标页面的访问请求后就开始执行。
可选的,对于不同的目标页面,调用函数有所不同,为了隔离不同目标页面的调用函数,可获取目标页面的页面上下文信息(Page Context),根据页面上下文信息以及目标页面的数据块数量,生成多个调用函数,其中任一调用函数的输入为页面上下文信息,输出为对应的数据块,其中目标页面的数据块数量用于限定多个调用函数的数量,也即多个调用函数的数量等于目标页面的数据块数量,而页面上下文通常指的是在服务端处理页面时与特定页面或会话相关联的数据或状态,包括但不限于终端设备信息、会话变量、请求参数、目标页面的URL(Uniform Resource Location,统一资源定位符)等,其中页面上下文信息是为了区分不同的目标页面,以避免存在多个不同的目标页面并发的场景下无法区分调用函数,也即实现不同目标页面之间的隔离,同时也使得同一个目标页面的不同调用函数使用和共享相同的页面上下文信息,并且也能够与后续流式渲染过程中的预设数据获取接口适配。
可选的,可以采用预设转换器模块来生成调用函数,具体的,可将目标页面的页面上下文信息以及目标页面的数据块数量作为输入,调用预设转换器模块,由预设转换器模块来生成所述多个调用函数。其中预设转换模块具体可采用任意可行的算法实现调用函数的生成。需要说明的是,为了解决多个不同的目标页面并发场景中对预设转换模块的调用,使得不同的目标页面之间调用预设转换模块时隔离页面上下文信息,而同一个目标页面调用预设转换模块生成不同调用函数时共享页面上下文信息,可借助Node原生模块async_hooks来实现。
S203、对所述目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将所述流式渲染结果返回给所述终端设备,以使所述终端设备根据所述流式渲染结果显示所述目标页面。
在本实施例中,采用流式渲染方式对目标页面进行渲染,在传统的流式渲染中通常需要从服务端以流(chunk-by-chunk)的形式分段获取目标页面的数据(分段传输超文本标记语言HTML数据)进行渲染,而服务端渲染过程中获取页面数据通常采用预设数据获取接口来请求,而预设数据获取接口通常只能处理一次性返回的页面数据,无法处理多次返回的页面数据,也即在传统的流式渲染中,预设数据获取接口的数量需要等于目标页面的分段数量,且每一预设数据获取接口触发一次请求(例如向数据库请求)获取一段页面数据,也即需要进行多次请求,而由于本实施例中由于业务需要只存在一个流式接口,因此可通过预设数据获取接口分别调用上文中生成的多个调用函数以获取对应的数据块,来模拟传统的流式渲染中预设数据获取接口发送一次请求获取目标页面的分段数据。在获取到数据块后可根据数据块继续进行流式渲染的其他操作。
具体的,如图3所示,在渲染过程中可以在不同阶段通过预设数据获取接口调用不同调用函数以获取对应的数据块,并进行渲染得到渲染结果发送给终端设备,一个阶段渲染完毕后,再进行下一阶段的调用和渲染。此外图3中的初始化过程包括获取页面上下文信息、生成调用函数等过程,此处不再展开赘述。
可选的,在分别根据各数据块进行渲染,得到流式渲染结果时,可分别根据每一数据块进行渲染,得到流式超文本标记语言HTML数据,将所述流式HTML数据作为所述流式渲染结果。其中,流式接口接收到的数据块可能并不是HTML数据,例如可能是JSON数据,因此需要在预设数据获取接口调用任一调用函数以获取对应的数据块后,可将数据块加工为HTML数据,以对HTML数据进行渲染。
此外,在传统的流式渲染中预设数据获取接通常需要根据页面上下文信息来请求数据(例如从数据库请求数据),也即页面上下文信息为预设数据获取接口的输入,而本实施例中调用函数的输入也被设计为页面上下文信息,也即在渲染过程中通过预设数据获取接口分别调用多个调用函数,并分别向多个调用函数输入页面上下文信息,分别获取多个调用函数输出的对应的数据块,从而可以正常向预设数据获取接口输入页面上下文信息,而模拟预设数据获取接口基于页面上下文信息请求数据块,且调用函数可以与预设数据获取接口适配,也即消费页面上下文信息而输出数据块。
本实施例提供的页面渲染方法,通过接收终端设备发送的对目标页面的访问请求,并通过一个流式接口异步获取所述目标页面的多个数据块;针对所述流式接口,生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块;对所述目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将所述流式渲染结果返回给所述终端设备,以使所述终端设备根据所述流式渲染结果显示所述目标页面。本实施例服务端通过一个流式接口获取目标页面的多个数据块,并通过调用函数的方式在流式渲染过程中调用流式接口获取的多个数据块,使得流式渲染阶段无需采用多个接口请求数据块,实现了流式接口与流式渲染的结合,减少接口数量和接口耗时,并且提高了目标页面的渲染速度,减少终端设备用户的等待时长,提升用户浏览目标页面的体验。
在上述任一实施例的基础上,目标页面的多个数据块具体可包括第一数据块、第二数据块以及第三数据块;其中第一数据块为目标页面的预测页面内容对应的数据块,预测页面内容为通过预测模型根据访问请求获取的页面内容,预测模型是服务端根据访问请求快速预测目标页面中一部分页面内容的模型,例如对于feed流播放器页面,可以通过预测模型根据访问请求预测feed流播放器页面中的首个多媒体内容;第二数据块为用于表征预测页面内容的预测有效性的数据块,可选的,预测有效性可以由服务端通过搜索引擎对目标页面获取的实际页面内容与预测页面内容进行比较而确定,其中目标页面的实际页面内容是正常的通过搜索引擎对目标页面获取的页面内容,通过将预测页面内容与目标页面获取的实际页面内容中对应部分进行比较,可以确定预测页面内容的预测有效性,可选的,服务端在通过搜索引擎对目标页面获取的页面内容时,可优先获取与预测页面内容对应部分,以便于更早获取到第二数据块,可选的,预测有效性可以用布尔值来标识;第三数据块为目标页面的实际页面内容对应的数据块,实际页面内容为通过搜索引擎根据访问请求获取的页面内容,且根据预测页面内容的预测有效性确定第三数据块中是否包括预测页面内容,也即若预测页面内容预测得有效,则第一数据块有效,第三数据块中可以不包括预测页面内容,无需重复发送预测页面内容以减少第三数据块的数据量,若预测页面内容预测无效,则第一数据块无效,第三数据块中需要包括目标页面完整的实际页面内容。
在上述实施例的基础上,S203在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,具体可包括:
在渲染过程中通过预设数据获取接口优先调用所述第二数据块对应的调用函数以获取所述第二数据块;
若所述第二数据块表征了所述预测页面内容预测有效,则通过预设数据获取接口调用所述第一数据块对应的调用函数以获取所述第一数据块,根据所述第一数据块对所述目标页面进行局部渲染,以在所述目标页面中优先显示所述预测页面内容;再通过所述预设数据获取接口调用所述第三数据块对应的调用函数以获取所述第三数据块,并根据所述第三数据块对所述目标页面的剩余部分进行渲染。
在本实施例中,由于目标页面的多个数据块包括上述的第一数据块、第二数据块以及第三数据块,在渲染过程中通过预设数据获取接口优先调用第二数据块对应的调用函数以获取第二数据块,根据第二数据块确定预测页面内容是否预测有效,若确定预测有效,则说明第一数据块可用,而第一数据块较第三数据块可能更早被流式接口接收,因此可先通过预设数据获取接口调用第一数据块对应的调用函数以获取第一数据块,根据第一数据块对所述目标页面进行局部渲染,并将渲染结果发送给终端设备,使得终端设备上的目标页面中优先显示出第一数据块中包括的预测页面内容;再通过预设数据获取接口调用第三数据块对应的调用函数以获取第三数据块,并根据第三数据块对目标页面的剩余部分进行渲染,并将渲染结果发送给终端设备,通过上述过程使得用户先观看一部分页面内容、再观看剩余页面内容,减少用户等待时间。
此外,若所述第二数据块表征了所述预测页面内容预测不有效,则直接通过所述预设数据获取接口调用所述第三数据块对应的调用函数,以获取所述第三数据块,并根据所述第三数据块对所述目标页面的整个页面进行渲染。
在本实施例中,若在渲染过程中通过预设数据获取接口优先调用第二数据块对应的调用函数以获取第二数据块,根据第二数据块确定预测页面内容是否预测有效,若确定预测不有效,则说明第一数据块不可用,不需要通过预设数据获取接口调用第一数据块对应的调用函数以获取第一数据块,而是直接通过预设数据获取接口调用第三数据块对应的调用函数以获取第三数据块,由于预测页面内容预测得不有效,第三数据块中包括目标页面完整的实际页面内容,因此可根据第三数据块对目标页面的整个页面进行渲染,再将渲染结果发送给终端设备,其中渲染结果也可分段发送给终端设备。
对应于上文实施例的页面渲染方法,图4为本公开实施例提供的页面渲染设备的结构框图。为了便于说明,仅示出了与本公开实施例相关的部分。参照图4,所述页面渲染设备400包括:请求单元401、接收单元402、转换单元403、渲染单元404。
其中,请求单元401,用于接收终端设备发送的对目标页面的访问请求;
接收单元402,用于通过一个流式接口异步获取所述目标页面的多个数据块;
转换单元403,用于针对所述流式接口,生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块;
渲染单元404,用于对所述目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将所述流式渲染结果返回给所述终端设备,以使所述终端设备根据所述流式渲染结果显示所述目标页面。
在本公开的一个或多个实施例中,所述渲染单元404在分别根据各数据块进行渲染,得到流式渲染结果时,用于:
分别根据每一数据块进行渲染,得到流式超文本标记语言HTML数据,将所述流式HTML数据作为所述流式渲染结果。
在本公开的一个或多个实施例中,所述转换单元403在针对所述流式接口,生成多个调用函数时,用于:
获取所述目标页面的页面上下文信息,并根据所述页面上下文信息以及所述目标页面的数据块数量,生成所述多个调用函数,其中任一调用函数的输入为所述页面上下文信息,输出为对应的数据块。
在本公开的一个或多个实施例中,所述渲染单元404在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块时,用于:
在渲染过程中通过预设数据获取接口分别调用所述多个调用函数,并分别向所述多个调用函数输入所述页面上下文信息,分别获取所述多个调用函数输出的对应的数据块。
在本公开的一个或多个实施例中,所述转换单元403在根据所述页面上下文信息以及所述目标页面的数据块数量,生成所述多个调用函数时,用于:
将所述页面上下文信息以及所述目标页面的数据块数量作为输入,调用预设转换器模块,生成所述多个调用模块。
在本公开的一个或多个实施例中,所述多个数据块中包括第一数据块、第二数据块以及第三数据块;
其中所述第一数据块为所述目标页面的预测页面内容对应的数据块,所述预测页面内容为通过预测模型根据所述访问请求获取的页面内容;所述第二数据块为用于表征所述预测页面内容的预测有效性的数据块;所述第三数据块为所述目标页面的实际页面内容对应的数据块,所述实际页面内容为通过搜索引擎根据所述访问请求获取的页面内容,且根据所述预测页面内容的预测有效性确定所述第三数据块中是否包括所述预测页面内容。
在本公开的一个或多个实施例中,所述渲染单元404在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染时,用于:
在渲染过程中通过预设数据获取接口优先调用所述第二数据块对应的调用函数以获取所述第二数据块;
若所述第二数据块表征了所述预测页面内容预测有效,则通过预设数据获取接口调用所述第一数据块对应的调用函数以获取所述第一数据块,根据所述第一数据块对所述目标页面进行局部渲染,以在所述目标页面中优先显示所述预测页面内容;再通过所述预设数据获取接口调用所述第三数据块对应的调用函数以获取所述第三数据块,并根据所述第三数据块对所述目标页面的剩余部分进行渲染。
在本公开的一个或多个实施例中,所述渲染单元404还用于:
若所述第二数据块表征了所述预测页面内容预测不有效,则直接通过所述预设数据获取接口调用所述第三数据块对应的调用函数,以获取所述第三数据块,并根据所述第三数据块对所述目标页面的整个页面进行渲染。
本实施例提供的设备,可用于执行上述方法实施例的技术方案,其实现原理和技术效果类似,本实施例此处不再赘述。
参考图5,其示出了适于用来实现本公开实施例的电子设备500的结构示意图,该电子设备500可以为终端设备或服务器。其中,终端设备可以包括但不限于诸如移动电话、笔记本电脑、数字广播接收器、个人数字助理(Personal Digital Assistant,简称PDA)、平板电脑(Portable Android Device,简称PAD)、便携式多媒体播放器(Portable Media Player,简称PMP)、车载终端(例如车载导航终端)等等的移动终端以及诸如数字TV、台式计算机等等的固定终端。图5示出的电子设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。
如图5所示,电子设备500可以包括处理装置(例如中央处理器、图形处理器等)501,其可以根据存储在只读存储器(Read Only Memory,简称ROM)502中的程序或者从存储装置508加载到随机访问存储器(Random Access Memory,简称RAM)503中的程序而执行各种适当的动作和处理。在RAM 503中,还存储有电子设备500操作所需的各种程序和数据。处理装置501、ROM 502以及RAM 503通过总线504彼此相连。输入/输出(I/O)接口505也连接至总线504。
通常,以下装置可以连接至I/O接口505:包括例如触摸屏、触摸板、键盘、鼠标、摄像头、麦克风、加速度计、陀螺仪等的输入装置506;包括例如液晶显示器(Liquid Crystal Display,简称LCD)、扬声器、振动器等的输出装置507;包括例如磁带、硬盘等的存储装置508;以及通信装置509。通信装置509可以允许电子设备500与其他设备进行无线或有线通信以交换数据。虽然图5示出了具有各种装置的电子设备500,但是应理解的是,并不要求实施或具备所有示出的装置。可以替代地实施或具备更多或更少的装置。
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置509从网络上被下载和安装,或者从存储装置508被安装,或者从ROM 502被安装。在该计算机程序被处理装置501执行时,执行本公开实施例的方法中限定的上述功能。
需要说明的是,本公开上述的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(射频)等等,或者上述的任意合适的组合。
上述计算机可读介质可以是上述电子设备中所包含的;也可以是单独存在,而未装配入该电子设备中。
上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该电子设备执行时,使得该电子设备执行上述实施例所示的方法。
可以以一种或多种程序设计语言或其组合来编写用于执行本公开的操作的计算机程序代码,上述程序设计语言包括面向对象的程序设计语言—诸如Java、Smalltalk、C++,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(Local Area Network,简称LAN)或广域网(Wide Area Network,简称WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,该模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和/或流程图中的每个方框、以及框图和/或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本公开实施例中所涉及到的单元可以通过软件的方式实现,也可以通过硬件的方式来实现。其中,单元的名称在某种情况下并不构成对该单元本身的限定,例如,第一获取单元还可以被描述为“获取至少两个网际协议地址的单元”。
本文中以上描述的功能可以至少部分地由一个或多个硬件逻辑部件来执行。例如,非限制性地,可以使用的示范类型的硬件逻辑部件包括:现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、片上系统(SOC)、复杂可编程逻辑设备(CPLD)等等。
在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。
第一方面,根据本公开的一个或多个实施例,提供了一种页面渲染方法,应用于服务端,所述方法包括:
接收终端设备发送的对目标页面的访问请求,并通过一个流式接口异步获取所述目标页面的多个数据块;
针对所述流式接口,生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块;
对所述目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将所述流式渲染结果返回给所述终端设备,以使所述终端设备根据所述流式渲染结果显示所述目标页面。
根据本公开的一个或多个实施例,所述分别根据各数据块进行渲染,得到流式渲染结果,包括:
分别根据每一数据块进行渲染,得到流式超文本标记语言HTML数据,将所述流式HTML数据作为所述流式渲染结果。
根据本公开的一个或多个实施例,所述针对所述流式接口,生成多个调用函数,包括:
获取所述目标页面的页面上下文信息,并根据所述页面上下文信息以及所述目标页面的数据块数量,生成所述多个调用函数,其中任一调用函数的输入为所述页面上下文信息,输出为对应的数据块。
根据本公开的一个或多个实施例,所述在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,包括:
在渲染过程中通过预设数据获取接口分别调用所述多个调用函数,并分别向所述多个调用函数输入所述页面上下文信息,分别获取所述多个调用函数输出的对应的数据块。
根据本公开的一个或多个实施例,所述根据所述页面上下文信息以及所述目标页面的数据块数量,生成所述多个调用函数,包括:
将所述页面上下文信息以及所述目标页面的数据块数量作为输入,调用预设转换器模块,生成所述多个调用模块。
根据本公开的一个或多个实施例,所述多个数据块中包括第一数据块、第二数据块以及第三数据块;
其中所述第一数据块为所述目标页面的预测页面内容对应的数据块,所述预测页面内容为通过预测模型根据所述访问请求获取的页面内容;所述第二数据块为用于表征所述预测页面内容的预测有效性的数据块;所述第三数据块为所述目标页面的实际页面内容对应的数据块,所述实际页面内容为通过搜索引擎根据所述访问请求获取的页面内容,且根据所述预测页面内容的预测有效性确定所述第三数据块中是否包括所述预测页面内容。
根据本公开的一个或多个实施例,所述在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,包括:
在渲染过程中通过预设数据获取接口优先调用所述第二数据块对应的调用函数以获取所述第二数据块;
若所述第二数据块表征了所述预测页面内容预测有效,则通过预设数据获取接口调用所述第一数据块对应的调用函数以获取所述第一数据块,根据所述第一数据块对所述目标页面进行局部渲染,以在所述目标页面中优先显示所述预测页面内容;再通过所述预设数据获取接口调用所述第三数据块对应的调用函数以获取所述第三数据块,并根据所述第三数据块对所述目标页面的剩余部分进行渲染。
根据本公开的一个或多个实施例,所述方法还包括:
若所述第二数据块表征了所述预测页面内容预测不有效,则直接通过所述预设数据获取接口调用所述第三数据块对应的调用函数,以获取所述第三数据块,并根据所述第三数据块对所述目标页面的整个页面进行渲染。
第二方面,根据本公开的一个或多个实施例,提供了一种页面渲染设备,包括:
请求单元,用于接收终端设备发送的对目标页面的访问请求;
接收单元,用于通过一个流式接口异步获取所述目标页面的多个数据块;
转换单元,用于针对所述流式接口,生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块;
渲染单元,用于对所述目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将所述流式渲染结果返回给所述终端设备,以使所述终端设备根据所述流式渲染结果显示所述目标页面。
根据本公开的一个或多个实施例,所述渲染单元在分别根据各数据块进行渲染,得到流式渲染结果时,用于:
分别根据每一数据块进行渲染,得到流式超文本标记语言HTML数据,将所述流式HTML数据作为所述流式渲染结果。
根据本公开的一个或多个实施例,所述转换单元在针对所述流式接口,生成多个调用函数时,用于:
获取所述目标页面的页面上下文信息,并根据所述页面上下文信息以及所述目标页面的数据块数量,生成所述多个调用函数,其中任一调用函数的输入为所述页面上下文信息,输出为对应的数据块。
根据本公开的一个或多个实施例,所述渲染单元在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块时,用于:
在渲染过程中通过预设数据获取接口分别调用所述多个调用函数,并分别向所述多个调用函数输入所述页面上下文信息,分别获取所述多个调用函数输出的对应的数据块。
根据本公开的一个或多个实施例,所述转换单元在根据所述页面上下文信息以及所述目标页面的数据块数量,生成所述多个调用函数时,用于:
将所述页面上下文信息以及所述目标页面的数据块数量作为输入,调用预设转换器模块,生成所述多个调用模块。
根据本公开的一个或多个实施例,所述多个数据块中包括第一数据块、第二数据块以及第三数据块;
其中所述第一数据块为所述目标页面的预测页面内容对应的数据块,所述预测页面内容为通过预测模型根据所述访问请求获取的页面内容;所述第二数据块为用于表征所述预测页面内容的预测有效性的数据块;所述第三数据块为所述目标页面的实际页面内容对应的数据块,所述实际页面内容为通过搜索引擎根据所述访问请求获取的页面内容,且根据所述预测页面内容的预测有效性确定所述第三数据块中是否包括所述预测页面内容。
根据本公开的一个或多个实施例,所述渲染单元在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染时,用于:
在渲染过程中通过预设数据获取接口优先调用所述第二数据块对应的调用函数以获取所述第二数据块;
若所述第二数据块表征了所述预测页面内容预测有效,则通过预设数据获取接口调用所述第一数据块对应的调用函数以获取所述第一数据块,根据所述第一数据块对所述目标页面进行局部渲染,以在所述目标页面中优先显示所述预测页面内容;再通过所述预设数据获取接口调用所述第三数据块对应的调用函数以获取所述第三数据块,并根据所述第三数据块对所述目标页面的剩余部分进行渲染。
根据本公开的一个或多个实施例,所述渲染单元还用于:
若所述第二数据块表征了所述预测页面内容预测不有效,则直接通过所述预设数据获取接口调用所述第三数据块对应的调用函数,以获取所述第三数据块,并根据所述第三数据块对所述目标页面的整个页面进行渲染。
第三方面,根据本公开的一个或多个实施例,提供了一种电子设备,包括:至少一个处理器和存储器;
所述存储器存储计算机执行指令;
所述至少一个处理器执行所述存储器存储的计算机执行指令,使得所述至少一个处理器执行如上第一方面以及第一方面各种可能的设计所述的页面渲染方法。
第四方面,根据本公开的一个或多个实施例,提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,当处理器执行所述计算机执行指令时,实现如上第一方面以及第一方面各种可能的设计所述的页面渲染方法。
第五方面,根据本公开的一个或多个实施例,提供了一种计算机程序产品,包括计算机执行指令,当处理器执行所述计算机执行指令时,实现如上第一方面以及第一方面各种可能的设计所述的页面渲染方法。
以上描述仅为本公开的较佳实施例以及对所运用技术原理的说明。本领域技术人员应当理解,本公开中所涉及的公开范围,并不限于上述技术特征的特定组合而成的技术方案,同时也应涵盖在不脱离上述公开构思的情况下,由上述技术特征或其等同特征进行任意组合而形成的其它技术方案。例如上述特征与本公开中公开的(但不限于)具有类似功能的技术特征进行互相替换而形成的技术方案。
此外,虽然采用特定次序描绘了各操作,但是这不应当理解为要求这些操作以所示出的特定次序或以顺序次序执行来执行。在一定环境下,多任务和并行处理可能是有利的。同样地,虽然在上面论述中包含了若干具体实现细节,但是这些不应当被解释为对本公开的范围的限制。在单独的实施例的上下文中描述的某些特征还可以组合地实现在单个实施例中。相反地,在单个实施例的上下文中描述的各种特征也可以单独地或以任何合适的子组合的方式实现在多个实施例中。
尽管已经采用特定于结构特征和/或方法逻辑动作的语言描述了本主题,但是应当理解所附权利要求书中所限定的主题未必局限于上面描述的特定特征或动作。相反,上面所描述的特定特征和动作仅仅是实现权利要求书的示例形式。
Claims (12)
- 一种页面渲染方法,应用于服务端,所述方法包括:接收终端设备发送的对目标页面的访问请求,并通过一个流式接口异步获取所述目标页面的多个数据块;针对所述流式接口,生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块;对所述目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将所述流式渲染结果返回给所述终端设备,以使所述终端设备根据所述流式渲染结果显示所述目标页面。
- 根据权利要求1所述的方法,其中,所述分别根据各数据块进行渲染,得到流式渲染结果,包括:分别根据每一数据块进行渲染,得到流式超文本标记语言HTML数据,将所述流式HTML数据作为所述流式渲染结果。
- 根据权利要求1或2所述的方法,其中,所述针对所述流式接口,生成多个调用函数,包括:获取所述目标页面的页面上下文信息,并根据所述页面上下文信息以及所述目标页面的数据块数量,生成所述多个调用函数,其中任一调用函数的输入为所述页面上下文信息,输出为对应的数据块。
- 根据权利要求3所述的方法,其中,所述在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,包括:在所述渲染过程中通过所述预设数据获取所述接口分别调用所述多个调用函数,并分别向所述多个调用函数输入所述页面上下文信息,分别获取所述多个调用函数输出的对应的数据块。
- 根据权利要求3或4所述的方法,其中,所述根据所述页面上下文信息以及所述目标页面的数据块数量,生成所述多个调用函数,包括:将所述页面上下文信息以及所述目标页面的数据块数量作为输入,调用预设转换器模块,生成所述多个调用模块。
- 根据权利要求1-5任一项所述的方法,其中,所述多个数据块中包括第一数据块、第二数据块以及第三数据块;其中所述第一数据块为所述目标页面的预测页面内容对应的数据块,所述预测页面内容为通过预测模型根据所述访问请求获取的页面内容;所述第二数据块为用于表征所述预测页面内容的预测有效性的数据块;所述第三数据块为所述目标页面的实际页面内容对应的数据块,所述实际页面内容为通过搜索引擎根据所述访问请求获取的页面内容,且根据所述预测页面内容的预测有效性确定所述第三数据块中是否包括所述预测页面内容。
- 根据权利要求6所述的方法,其中,所述在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,包括:在所述渲染过程中通过所述预设数据获取所述接口优先调用所述第二数据块对应的调用函数以获取所述第二数据块;若所述第二数据块表征了所述预测页面内容预测有效,则通过所述预设数据获取所述接口调用所述第一数据块对应的调用函数以获取所述第一数据块,根据所述第一数据块对所述目标页面进行局部渲染,以在所述目标页面中优先显示所述预测页面内容;再通过所述预设数据获取所述接口调用所述第三数据块对应的调用函数以获取所述第三数据块,并根据所述第三数据块对所述目标页面的剩余部分进行渲染。
- 根据权利要求7所述的方法,还包括:若所述第二数据块表征了所述预测页面内容预测不有效,则直接通过所述预设数据获取所述接口调用所述第三数据块对应的调用函数,以获取所述第三数据块,并根据所述第三数据块对所述目标页面的整个页面进行渲染。
- 一种页面渲染设备,包括:请求单元,被配置为接收终端设备发送的对目标页面的访问请求;接收单元,被配置为通过一个流式接口异步获取所述目标页面的多个数据块;转换单元,被配置为针对所述流式接口,生成多个调用函数,其中每个调用函数用于调用所述流式接口接收到的一个数据块;渲染单元,被配置为对所述目标页面采用流式渲染方式进行渲染,在渲染过程中通过预设数据获取接口分别调用所述多个调用函数以获取对应的数据块,并分别根据各数据块进行渲染,得到流式渲染结果,并将所述流式渲染结果返回给所述终端设备,以使所述终端设备根据所述流式渲染结果显示所述目标页面。
- 一种电子设备,包括至少一个处理器和存储器,其中,所述存储器被配置为存储计算机执行指令;所述至少一个处理器被配置为执行所述存储器存储的计算机执行指令,使得所述至少一个处理器执行如权利要求1-8任一项所述的页面渲染方法。
- 一种计算机可读存储介质,存储有计算机执行指令,其中,当处理器执行所述计算机执行指令时,实现如权利要求1-8任一项所述的页面渲染方法。
- 一种计算机程序产品,包括计算机执行指令,其中,当处理器执行所述计算机执行指令时,实现如权利要求1-8任一项所述的页面渲染方法。
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410382056.1 | 2024-03-29 | ||
| CN202410382056.1A CN120723989A (zh) | 2024-03-29 | 2024-03-29 | 页面渲染方法、设备及存储介质 |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2025201412A1 true WO2025201412A1 (zh) | 2025-10-02 |
Family
ID=97165786
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2025/085051 Pending WO2025201412A1 (zh) | 2024-03-29 | 2025-03-26 | 页面渲染方法、设备及存储介质 |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN120723989A (zh) |
| WO (1) | WO2025201412A1 (zh) |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111859224A (zh) * | 2020-07-31 | 2020-10-30 | 平安健康保险股份有限公司 | 基于节点服务器的服务端渲染方法、装置和计算机设备 |
| CN113821737A (zh) * | 2021-09-29 | 2021-12-21 | 中国平安财产保险股份有限公司 | 单页面应用的地图渲染方法、装置、设备及存储介质 |
| CN115758023A (zh) * | 2022-11-22 | 2023-03-07 | 平安银行股份有限公司 | 页面的预渲染方法、装置及电子设备 |
| CN117614903A (zh) * | 2023-10-25 | 2024-02-27 | 北京声智科技有限公司 | 小程序页面渲染方法、装置、电子设备及存储介质 |
-
2024
- 2024-03-29 CN CN202410382056.1A patent/CN120723989A/zh active Pending
-
2025
- 2025-03-26 WO PCT/CN2025/085051 patent/WO2025201412A1/zh active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN111859224A (zh) * | 2020-07-31 | 2020-10-30 | 平安健康保险股份有限公司 | 基于节点服务器的服务端渲染方法、装置和计算机设备 |
| CN113821737A (zh) * | 2021-09-29 | 2021-12-21 | 中国平安财产保险股份有限公司 | 单页面应用的地图渲染方法、装置、设备及存储介质 |
| CN115758023A (zh) * | 2022-11-22 | 2023-03-07 | 平安银行股份有限公司 | 页面的预渲染方法、装置及电子设备 |
| CN117614903A (zh) * | 2023-10-25 | 2024-02-27 | 北京声智科技有限公司 | 小程序页面渲染方法、装置、电子设备及存储介质 |
Also Published As
| Publication number | Publication date |
|---|---|
| CN120723989A (zh) | 2025-09-30 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2022151966A1 (zh) | 用于语言模型的处理方法、文本生成方法、装置及介质 | |
| US11714866B2 (en) | Method and device for page processing, electronic device, and computer-readable storage medium | |
| CN114089920B (zh) | 数据存储方法、装置、可读介质及电子设备 | |
| CN111309304B (zh) | 一种生成idl文件的方法、装置、介质和电子设备 | |
| WO2022116819A1 (zh) | 模型训练方法及装置、机器翻译方法及装置、设备、存储介质 | |
| CN111752644A (zh) | 接口模拟方法、装置、设备及存储介质 | |
| WO2024198920A1 (zh) | 内容推送模型的训练方法、装置、设备及存储介质 | |
| WO2025200494A1 (zh) | 一种消息处理方法、装置、设备及介质 | |
| WO2022134968A1 (zh) | 模型的训练方法、语音识别方法、装置、介质及设备 | |
| CN112835671A (zh) | 应用页面场景切换方法、装置及设备 | |
| WO2025201412A1 (zh) | 页面渲染方法、设备及存储介质 | |
| CN114786069B (zh) | 视频生成方法、装置、介质及电子设备 | |
| CN115409044B (zh) | 翻译方法、装置、可读介质及电子设备 | |
| CN113850055B (zh) | 数据处理方法、设备、存储介质及产品 | |
| CN113240107B (zh) | 图像处理方法、装置和电子设备 | |
| CN115242862A (zh) | 网络请求控制方法、装置、介质以及电子设备 | |
| CN111968028A (zh) | 图像生成方法、装置、设备和计算机可读介质 | |
| CN112631592B (zh) | 数据请求方法、装置、设备、介质及程序产品 | |
| US20250200876A1 (en) | Data transmission method and device | |
| CN111523330A (zh) | 用于生成文本的方法、装置、电子设备和介质 | |
| WO2025201506A1 (zh) | 图片加载方法、设备及存储介质 | |
| CN111310483B (zh) | 一种翻译方法、装置、电子设备及存储介质 | |
| CN118152683A (zh) | 内容渲染方法、装置、可读介质及电子设备 | |
| CN118229858A (zh) | 图像处理方法、装置、终端和存储介质 | |
| WO2025045249A1 (zh) | 一种数据处理方法、装置、电子设备及存储介质 |
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: 25778243 Country of ref document: EP Kind code of ref document: A1 |