A visual method for realizing static page
The method addresses dynamic web page inefficiencies by statically visualizing pages with placeholder replacement and asynchronous loading, enhancing response speed and SEO while reducing system load.
Patent Information
- Application Number
- CN202411420759.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-10-12
AI Technical Summary
Dynamic web pages face issues with slow rendering, high interaction request loads, and poor SEO due to frequent back-end interactions, which increase system response pressure and timeouts.
A method for realizing static page visualization through generating a template file, setting placeholders, obtaining static data, replacing keywords, and asynchronously loading dynamic components, utilizing a front-end and back-end separated architecture to simplify rendering logic and manage components independently.
Ensures fast visual response with dynamic interactive effects, improves SEO, and reduces system load by simplifying component management and rendering processes.
Smart Images

Figure CN118916561B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of digital visualization, and in particular to a method for realizing static visualization of a page. Background Art
[0002] With the continuous popularization and development of network technology, the content presented by web pages is becoming more and more rich and diverse. In the current web page development and design, we usually use front-end framework technology to build dynamic pages. Dynamic web pages are not special web page files like static web pages. They exist in the database and will only return a web page when the user makes a request. The content of the web page can be dynamically changed according to the user's requirements.
[0003] Compared with static web pages, dynamic web pages are generated using database content, which is not conducive to search engine retrieval and SEO (search engine optimization); and when loading the first screen, dynamic pages also have the problem of slow rendering; in addition, in some official website systems, since the frequency of adjustment of web page display content items is not high, if the traditional front-end and back-end request interaction method is used, it will bring a large number of interaction requests to the system, and frequent interaction requests will also bring a large response pressure to the system, resulting in response timeouts.
[0004] Therefore, a visual page staticization implementation method is needed to solve the above technical problems. Summary of the invention
[0005] In order to solve the above technical problems, the present invention provides a visual method for realizing page staticization, which realizes page staticization through the following steps:
[0006] Step S1: Generate a first template file through the framework homepage file;
[0007] Step S2: Setting keyword placeholders in the first template file;
[0008] Step S3: Obtain static data of the first template file through the browser, and send the static data to the server;
[0009] Step S4: the server receives the static data, generates a file address from the static data and replaces the keywords in the first template file;
[0010] Step S5: After the keyword replacement is completed, a static page is obtained and displayed first;
[0011] Step S6: asynchronously load the dynamic component into the static page;
[0012] Step S7: After the asynchronous loading is completed, the rendered static rendering page is obtained, the original static rendering page is hidden, and the static rendering page is displayed in a secondary manner.
[0013] As a further solution, the keywords include keyword title, keyword address and keyword hypertext markup language.
[0014] As a further solution, the static data includes URL data, data source data, HTML and CSS data.
[0015] As a further solution, the step S6 further includes that after the server receives the static data, the server directly replaces the keywords in the first template file with the static data.
[0016] As a further solution, when the page is statically rendered locally, the static data of the first template file is captured by the local browser.
[0017] As a further solution, when the page is statically implemented in the back end, the back end calls the simulated browser plug-in provided by nodejs, and captures the static data of the first template file through the simulated browser plug-in.
[0018] As a further solution, local page staticization and back-end page staticization are combined.
[0019] As a further solution, in step S5, a random character string is output as the name of the static page, and there is a one-to-one correspondence between the random character string output each time and the static page.
[0020] As a further solution, the page staticization implementation method further includes updating the static rendering page;
[0021] Update static rendering pages including immediate update and hot update;
[0022] The immediate update is to re-execute steps S1 to S7;
[0023] The hot update is to execute steps S3 to S7.
[0024] As a further solution, keywords in the first template file are automatically replaced by a shell script.
[0025] Compared with the related art, the method for realizing static page visualization provided by the present invention has the following beneficial effects:
[0026] The present invention firstly displays the static page to ensure the visual response speed; then asynchronously loads the dynamic component into the static page, hides the static page after rendering is completed, and replaces it with the static rendering page, so that the static page has a dynamic interactive effect; in addition, since the present embodiment adopts a front-end and back-end separated architecture mode, page construction is realized by component combination, and the rendering of its components is independent of the back-end logic. By utilizing the browser to assemble data and utilizing its natural rendering logic to obtain static data, there is no need to construct complex rendering logic and manage different versions of rendering components; the present invention utilizes existing browsers to assemble data, can efficiently implement the component rendering process and obtain static data, and greatly simplifies the operation process and complexity. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 A schematic diagram of the steps of a visualized method for implementing static page conversion provided by the present invention. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0029] Example 1
[0030] This embodiment provides a visual method for implementing static page. For its execution process, please refer to Figure 1 , make the page static through the following steps:
[0031] Step S1: Generate a first template file through the framework homepage file;
[0032] Step S2: Setting keyword placeholders in the first template file;
[0033] Step S3: Obtain static data of the first template file through the browser, and send the static data to the server;
[0034] Step S4: the server receives the static data, generates a file address from the static data and replaces the keywords in the first template file;
[0035] Step S5: After the keyword replacement is completed, a static page is obtained and displayed first;
[0036] Step S6: asynchronously load the dynamic component into the static page;
[0037] Step S7: After the asynchronous loading is completed, the rendered static rendering page is obtained, the original static rendering page is hidden, and the static rendering page is displayed in a secondary manner.
[0038] It should be noted that the index.html using a dynamic page framework does not contain content, which is not conducive to SEO; and there are a large number of business interface requests in the dynamic page, and dynamic rendering of a large amount of content at the same time will slow down the page display speed. Therefore, staticization is a necessary means to solve these problems.
[0039] However, the current conventional static methods cannot meet the requirements of low-code asynchronous component loading. The existing static technologies are as follows: Method 1: Conventional back-end static publishing methods usually include using template syntax on the server side to generate static pages; however, users need to understand the back-end code, the technical cost is high, and it is more complicated to modify; in addition, the interaction logic is usually fixed in the code of the project framework, lacks the concept of componentization, and does not meet the technical requirements of the visual low-code platform.
[0040] Method 2: Using the Vue SSR framework to render components and output HTML is a feasible solution. On the server side, it can pull business data, page data, and component data, and then dynamically render and output HTML. The dynamic interaction logic is contained in the component, so the browser side also needs to implement the function of taking over the SSR output, that is, isomorphic rendering. However, this method is more complicated to implement: 1. There are version issues with the components. The server side needs to obtain many asynchronous resources to successfully render the page, so a complete set of component versions needs to be managed synchronously; 2. The components need to use external data, which will cause excessive pressure on the server; 3. There are version issues with the visualization platform. Compiling and outputting a set of pages will take a lot of time, which increases the technical difficulty and maintenance complexity.
[0041] This embodiment firstly displays the static page first to ensure the visual response speed; then asynchronously loads the dynamic component into the static page, hides the static page after rendering is completed, and replaces it with a static rendering page, so that the static page has a dynamic interactive effect.
[0042] In addition, since this embodiment adopts a front-end and back-end separated architecture mode, page construction is achieved through component combination; therefore, the rendering of its components is independent of the back-end logic. By utilizing the browser to assemble data and utilizing its natural rendering logic to obtain static data, there is no need to construct complex rendering logic and manage different versions of rendering components.
[0043] This method of assembling data using existing browsers can obtain static data more simply and directly, and is no different from opening a browser to access it. It can efficiently implement the component rendering process and obtain static data, greatly simplifying the operation process and complexity.
[0044] This embodiment realizes accurate corresponding output of loading static content and rendering of dynamic components to achieve consistent display effect; since components can be selected to be static or non-static, static content customization is realized; at this time, the page has both static and dynamic logics, realizing overlapping correspondence of static and dynamic display effects in the page, as well as static assembly and management of data; therefore, it can solve SEO problems and achieve faster presentation speed, and also have dynamic interactive effects.
[0045] As a further solution, the keywords include keyword title, keyword address and keyword hypertext markup language.
[0046] In some specific embodiments, the keyword title is named TPL_STATIC_TITLE, the keyword hypertext markup language is named TPL_STATIC_HTML, and the keyword address is named TPL_STATIC_BASICJS;
[0047] The purpose of setting keyword placeholders is to replace the parts that need to be replaced later, namely the title of the business data and the address of the data;
[0048] The server executes a shell script to replace the keywords in the first template file, for example, to replace the keyword hypertext language with HTML in the static data. The program language is as follows:
[0049]
[0050] TPL_STATIC_HTML
[0051]
[0052] As a further solution, the static data includes URL data, data source data, HTML and CSS data.
[0053] It should be noted that: this embodiment makes the URL parameters static, which can shorten the URL address, help to compress resource usage and improve response rate; the page content is static, which is conducive to search engine optimization.
[0054] As a further solution, the step S6 further includes that after the server receives the static data, the server directly replaces the keywords in the first template file with the static data.
[0055] As a further solution, when the page is statically rendered locally, the static data of the first template file is captured by the local browser.
[0056] As a further solution, when the page is statically implemented in the back end, the back end calls the simulated browser plug-in provided by nodejs, and captures the static data of the first template file through the simulated browser plug-in.
[0057] As a further solution, local page staticization and back-end page staticization are combined.
[0058] It should be noted that opening locally is more friendly to a single or a small number of pages. Therefore, local static generation is selected. Of course, the user's network conditions may affect the efficiency of publishing. If too many pages need to be published at one time, it is not possible to execute them in the local browser. Therefore, the simulated browser plug-in provided by nodejs is used to implement backend static generation, which is both efficient and stable.
[0059] Note: This plug-in is used for static data crawling. Its principle is to simulate a browser to open a web page and then obtain the data on the web page, similar to a data crawler.
[0060] As a further solution, in step S5, a random character string is output as the name of the static page, and there is a one-to-one correspondence between the random character string output each time and the static page.
[0061] It should be noted that: this embodiment aims to achieve a one-to-one correspondence between random character strings and static pages, so as to facilitate version management of static pages.
[0062] As a further solution, the page staticization implementation method further includes updating the static rendering page;
[0063] Update static rendering pages including immediate update and hot update;
[0064] The immediate update is to re-execute steps S1 to S7;
[0065] The hot update is to execute steps S3 to S7.
[0066] It should be noted that immediate update is to republish all related pages and re-execute static publishing based on the association between data and pages. Hot update is to read the update status of data and pages when users visit the old version of static pages. If the page needs to be updated, the simulated browser plug-in of Node.js is used on the server to re-execute the static operation on the page.
[0067] The hot update method can improve efficiency without having to perform it on all related pages immediately. You only need to update once when checking for dependent updates for the first time, and then you can access the latest HTML. However, users who visit the page for the first time may not get the latest data immediately, but access the old version of HTML. This does not affect usage, but helps improve efficiency.
[0068] As a further solution, keywords in the first template file are automatically replaced by a shell script.
[0069] It should be noted that shell scripts can be easily edited, further lowering the technical threshold for static implementation.
[0070] The above are only embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for realizing static visualization of a page, characterized in that: Make the page static by following these steps: Step S1: Generate a first template file through the framework homepage file; Step S2: Setting keyword placeholders in the first template file; Step S3: Obtain static data of the first template file through the browser, and send the static data to the server; Step S4: the server receives the static data, generates a file address from the static data and replaces the keywords in the first template file; Step S5: After the keyword replacement is completed, a static page is obtained and displayed first; Step S6: asynchronously load the dynamic component into the static page; Step S7: After the asynchronous loading is completed, the rendered static rendering page is obtained, the original static rendering page is hidden, and the static rendering page is displayed in a secondary manner.
2. A method for realizing static visualization of a page according to claim 1, characterized in that: The keywords include keyword title, keyword address and keyword hypertext markup language.
3. A method for realizing static visualization of a page according to claim 1, characterized in that: The static data includes URL data, data source data, HTML and CSS data.
4. A method for realizing static visualization of a page according to claim 1, characterized in that: The step S6 also includes that after the server receives the static data, the static data is directly used to replace the keywords in the first template file.
5. The method for realizing static visualization of a page according to claim 1, characterized in that: When the page is statically rendered locally, the static data of the first template file is captured by the local browser.
6. A method for realizing static visualization of a page according to claim 1, characterized in that: When the page is statically made in the backend, the backend calls the simulated browser plug-in provided by nodejs, and grabs the static data of the first template file through the simulated browser plug-in.
7. A method for realizing static visualization of a page according to any one of claim 5 or claim 6, characterized in that: Combine local implementation of page staticization with backend implementation of page staticization.
8. A method for realizing static visualization of a page according to claim 1, characterized in that: In step S5, a random character string is output as the name of the static page, and there is a one-to-one correspondence between the random character string output each time and the static page.
9. A method for realizing static visualization of a page according to claim 1, characterized in that: The page staticization implementation method also includes updating the static rendering page; Update static rendering pages including immediate update and hot update; The immediate update is to re-execute steps S1 to S7; The hot update is to execute steps S3 to S7.
10. The method for realizing static visualization of a page according to claim 1, characterized in that: Automatically replace keywords in the first template file through shell script.
Citation Information
Patent Citations
Content management system, static page management method and device and storage medium
CN114329297A
Webpage content static processing method and system
CN115758016A
