Method and system for improving static generation efficiency of webpage in total station

文档序号:1904791 发布日期:2021-11-30 浏览:6次 中文

阅读说明:本技术 提高网页全站静态化生成效率的方法及系统 (Method and system for improving static generation efficiency of webpage in total station ) 是由 高军涛 张阳光 何文欢 姚金龙 于 2021-09-02 设计创作,主要内容包括:本发明属于网页制作技术领域,公开一种提高网页全站静态化生成效率的方法及系统,该方法包括:步骤1,生成模板文件:提前为不同的网页生成模板文件,其中业务数据采用约定的变量,通过占位符进行占位;步骤2,生成指定格式的业务数据:添加业务数据,在数据库保留一份用于归档外,还自动在指定的目录下生成JSON文件或者放入缓存,将需要读取或者不经常变化的业务数据放入JSON文件,将需要写入或经常变化的业务数据放入缓存;步骤3,将业务数据和模板文件建立关联,生成静态页。本发明使服务器的资源能合理的利用,又能满足数据实时变化的需求。(The invention belongs to the technical field of webpage making, and discloses a method and a system for improving the generation efficiency of static webpage total stations, wherein the method comprises the following steps: step 1, generating a template file: generating template files for different webpages in advance, wherein the business data adopt appointed variables and occupy the place through placeholders; step 2, generating service data in a specified format: adding service data, automatically generating a JSON file under a specified directory or putting the JSON file into a cache besides reserving a copy of the JSON file for filing in a database, putting the service data which needs to be read or does not change frequently into the JSON file, and putting the service data which needs to be written or changes frequently into the cache; and 3, establishing association between the service data and the template file to generate a static page. The invention can reasonably utilize the resources of the server and meet the requirement of real-time change of data.)

1. A method for improving static generation efficiency of a webpage total station is characterized by comprising the following steps:

step 1, generating a template file: generating template files for different webpages in advance, wherein the business data adopt appointed variables and occupy the place through placeholders;

step 2, generating service data in a specified format: adding service data, automatically generating a JSON file under a specified directory or putting the JSON file into a cache besides reserving a copy of the JSON file for filing in a database, putting the service data which needs to be read or does not change frequently into the JSON file, and putting the service data which needs to be written or changes frequently into the cache;

and 3, establishing association between the service data and the template file to generate a static page.

2. The method for improving the efficiency of generating static web pages in total stations according to claim 1, wherein the generating template files for different web pages in advance comprises:

freely dragging the template elements to combine to generate a template file; the template elements comprise a cable label, a text box, a text field, a drop-down box, a radio box, a check box, uploading, picture carousel, a button and a combination element;

and assembling and modifying the template by dragging the template elements, adding template attribute items, and generating different types of template files.

3. The method for improving the efficiency of generating the web page in the total station staticizing mode according to claim 2, wherein the template files are divided into a header template file, a navigation template file, a content display area template file, a trailer template file and other public template files according to different display areas.

4. The method for improving the efficiency of generating the static web pages in the total station according to claim 1, wherein the static pages are divided into a home page template, a pagination template and a detail page template according to different display contents.

5. The method for improving the efficiency of generating the static web pages in the total station according to claim 4, wherein the step 3 includes:

for the home page template and the detail page template, replacing placeholders in the template file according to JSON files or cache data of business data, and generating corresponding static pages in real time;

for the paging template, configuring scheduling frequency and time according to the real-time requirement of data, and generating a corresponding static page;

and for service data with complex service and real-time change, performing secondary request cache or a database in an asynchronous loading mode.

6. The utility model provides a system for improve webpage total station staticizing generation efficiency which characterized in that includes:

the template file generation module is used for generating a template file: generating template files for different webpages in advance, wherein the business data adopt appointed variables and occupy the place through placeholders;

the service data generation module is used for generating service data in a specified format: adding service data, automatically generating a JSON file under a specified directory or putting the JSON file into a cache besides reserving a copy of the JSON file for filing in a database, putting the service data which needs to be read or does not change frequently into the JSON file, and putting the service data which needs to be written or changes frequently into the cache;

and the association module is used for establishing association between the service data and the template file to generate a static page.

7. The system for improving the efficiency of generating the static web pages in the total station of claim 6, wherein the template file generating module comprises:

the free combination submodule is used for freely dragging the template elements to combine to generate a template file; the template elements comprise a cable label, a text box, a text field, a drop-down box, a radio box, a check box, uploading, picture carousel, a button and a combination element;

and the assembling and modifying submodule is used for assembling and modifying the template by dragging the template elements, adding the attribute items of the template and generating template files of different types.

8. The system for improving the efficiency of generating the web page total station staticizing as claimed in claim 7, wherein the template files are divided into a header template file, a navigation template file, a content display area template file, a trailer template file, and other public template files according to different display areas.

9. The system for improving the efficiency of generating static pages in a web page total station as claimed in claim 6, wherein the static pages are divided into a home page template, a pagination template and a detail page template according to different display contents.

10. The system for improving efficiency of generating static web pages in total stations according to claim 9, wherein the correlation module includes:

the first static page generation submodule is used for replacing a placeholder in a template file according to JSON (Java Server object notation) files or cache data of service data for a home page template and a detail page template and generating a corresponding static page in real time;

the second static page generation submodule is used for configuring scheduling frequency and time according to the real-time requirement of data for the paging template to generate a corresponding static page;

and the third static page generation submodule is used for performing secondary request cache or a database on the service data with complex service and real-time change by adopting an asynchronous loading mode.

Technical Field

The invention belongs to the technical field of webpage making, and particularly relates to a method and a system for improving the generation efficiency of webpage total station staticization.

Background

Front-end page display technologies of websites are roughly divided into four categories, which are JSP pages, PHP pages, ASP pages, and static HTML pages. JSP, PHP and ASP are dynamic web languages, dynamic data can be added into HTML pages, so that the contents displayed by the pages are richer, different contents can be displayed according to different visitors, but the dynamic web pages need persistent support of data such as a database and the like, and particularly under the conditions of large data volume, high concurrency and complex data structure, the resource consumption of a server is high, the opening speed of the web pages is slow and the like. How to generate a dynamic and static combined webpage through technologies such as template engines, asynchronous loading, public templates, caching, scheduling of planned tasks and the like is the problem to be solved by the method, so that resources of a server can be reasonably utilized, and the requirement of real-time change of data can be met.

Disclosure of Invention

The invention provides a method and a system for improving the generation efficiency of the static state of a webpage in a total station, aiming at the problems that a dynamic webpage needs persistent support of data such as a database and the like, and particularly under the conditions of large data volume, high concurrency and complex data structure, the resource consumption of a server is high and the opening speed of the webpage is low.

In order to achieve the purpose, the invention adopts the following technical scheme:

the invention provides a method for improving the generation efficiency of the static web page total station on one hand, which comprises the following steps:

step 1, generating a template file: generating template files for different webpages in advance, wherein the business data adopt appointed variables and occupy the place through placeholders;

step 2, generating service data in a specified format: adding service data, automatically generating a JSON file under a specified directory or putting the JSON file into a cache besides reserving a copy of the JSON file for filing in a database, putting the service data which needs to be read or does not change frequently into the JSON file, and putting the service data which needs to be written or changes frequently into the cache;

and 3, establishing association between the service data and the template file to generate a static page.

Further, the generating template files for different webpages in advance includes:

freely dragging the template elements to combine to generate a template file; the template elements comprise a cable label, a text box, a text field, a drop-down box, a radio box, a check box, uploading, picture carousel, a button and a combination element;

and assembling and modifying the template by dragging the template elements, adding template attribute items, and generating different types of template files.

Further, the template files are divided into a head template file, a navigation template file, a content display area template file, a tail template file and other public template files according to different display areas.

Further, the static pages are divided into a home page template, a paging template and a detail page template according to different display contents.

Further, the step 3 comprises:

for the home page template and the detail page template, replacing placeholders in the template file according to JSON files or cache data of business data, and generating corresponding static pages in real time;

for the paging template, configuring scheduling frequency and time according to the real-time requirement of data, and generating a corresponding static page;

and for service data with complex service and real-time change, performing secondary request cache or a database in an asynchronous loading mode.

In another aspect, the present invention provides a system for improving static generation efficiency of a web page in a total station, including:

the template file generation module is used for generating a template file: generating template files for different webpages in advance, wherein the business data adopt appointed variables and occupy the place through placeholders;

the service data generation module is used for generating service data in a specified format: adding service data, automatically generating a JSON file under a specified directory or putting the JSON file into a cache besides reserving a copy of the JSON file for filing in a database, putting the service data which needs to be read or does not change frequently into the JSON file, and putting the service data which needs to be written or changes frequently into the cache;

and the association module is used for establishing association between the service data and the template file to generate a static page.

Further, the template file generation module comprises:

the free combination submodule is used for freely dragging the template elements to combine to generate a template file; the template elements comprise a cable label, a text box, a text field, a drop-down box, a radio box, a check box, uploading, picture carousel, a button and a combination element;

and the assembling and modifying submodule is used for assembling and modifying the template by dragging the template elements, adding the attribute items of the template and generating template files of different types.

Further, the template files are divided into a head template file, a navigation template file, a content display area template file, a tail template file and other public template files according to different display areas.

Further, the static pages are divided into a home page template, a paging template and a detail page template according to different display contents.

Further, the association module includes:

the first static page generation submodule is used for replacing a placeholder in a template file according to JSON (Java Server object notation) files or cache data of service data for a home page template and a detail page template and generating a corresponding static page in real time;

the second static page generation submodule is used for configuring scheduling frequency and time according to the real-time requirement of data for the paging template to generate a corresponding static page;

and the third static page generation submodule is used for performing secondary request cache or a database on the service data with complex service and real-time change by adopting an asynchronous loading mode.

Compared with the prior art, the invention has the following beneficial effects:

the invention firstly generates a template file: generating template files for different webpages in advance, wherein the business data adopt appointed variables and occupy the place through placeholders; then generating the service data with the specified format: adding service data, automatically generating a JSON file under a specified directory or putting the JSON file into a cache besides reserving a copy of the JSON file for filing in a database, putting the service data which needs to be read or does not change frequently into the JSON file, and putting the service data which needs to be written or changes frequently into the cache; and finally, establishing association between the service data and the template file to generate a static page: for the home page template and the detail page template, replacing placeholders in the template file according to JSON files or cache data of business data, generating corresponding static pages in real time, and not accessing a database; for the paging template, the scheduling frequency and time are configured according to the real-time requirement of data, a corresponding static page is generated, and by means of scheduling of a plan task, server resources are reasonably used without influencing service access; and for the service data with complex service and real-time change, performing secondary request cache or a database in an asynchronous loading mode, and displaying the service data. The invention can reasonably utilize the resources of the server and meet the requirement of real-time change of data.

Drawings

Fig. 1 is a basic flowchart of a method for improving static generation efficiency of a web page in a total station according to an embodiment of the present invention;

fig. 2 is a schematic structural diagram of a system for improving static generation efficiency of a web page in a total station according to an embodiment of the present invention.

Detailed Description

The invention is further illustrated by the following examples in conjunction with the accompanying drawings:

as shown in fig. 1, a method for improving static generation efficiency of a web page in a total station includes:

step S101, generating a template file: generating template files for different webpages in advance, wherein the business data adopt appointed variables and occupy the place through placeholders;

specifically, the template data is generally divided into a style file, a script file, a static resource, HTML, and the like, and the content of this portion is not substantially changed.

Further, in step S101, the generating (HTML) template files for different web pages in advance includes:

freely dragging the template elements to combine to generate a template file; the template elements comprise a cable label, a text box, a text field, a drop-down box, a radio box, a check box, uploading, picture carousel, a button, a combination element and the like;

and assembling and modifying the template by dragging the template elements, adding template attribute items, and generating different types of template files.

Further, the template files are divided into a head template file, a navigation template file, a content display area template file, a tail template file and other public template files according to different display areas; for common templates, reference can be made in other web pages, reducing duplicate generation. Specifically, for a title in the template file, $ { title } may be substituted first.

Step S102, generating service data with a specified format: adding service data, automatically generating a JSON file under a specified directory or putting the JSON file into a cache besides reserving a copy of the JSON file for filing in a database, putting the service data which needs to be read or does not change frequently into the JSON file, and putting the service data which needs to be written or changes frequently into the cache; so that the variables of the template file can be replaced through JS calling;

step S103, establishing association between the service data and the template file to generate a static page.

Further, the static pages are divided into a home page template, a paging template and a detail page template according to different display contents.

Further, the step S103 includes:

for the home page template and the detail page template, replacing placeholders in the template file according to JSON files or cache data of business data, and generating corresponding static pages in real time without accessing a database;

for the paging template, configuring scheduling frequency and time according to the real-time requirement of data, and generating a corresponding static page; by means of scheduling of the planned tasks, server resources are reasonably used, and access of services is not influenced;

and for service data with complex service and real-time change, performing secondary request cache or a database in an ajax asynchronous loading mode, and displaying the service data.

On the basis of the foregoing embodiment, as shown in fig. 2, the present invention further provides a system for improving static generation efficiency of a web page total station, including:

a template file generating module 201, configured to generate a template file: generating HTML template files for different webpages in advance, wherein the business data adopt appointed variables and occupy the place through placeholders;

a service data generating module 202, configured to generate service data in a specified format: adding service data, automatically generating a JSON file under a specified directory or putting the JSON file into a cache besides reserving a copy of the JSON file for filing in a database, putting the service data which needs to be read or does not change frequently into the JSON file, and putting the service data which needs to be written or changes frequently into the cache;

and the association module 203 is used for establishing association between the service data and the template file to generate a static page.

Further, the template file generating module 201 includes:

the free combination submodule is used for freely dragging the template elements to combine to generate an HTML template file; the template elements comprise a cable label, a text box, a text field, a drop-down box, a radio box, a check box, uploading, picture carousel, a button and a combination element;

and the assembling and modifying submodule is used for assembling and modifying the template by dragging the template elements, adding the attribute items of the template and generating template files of different types.

Further, the template files are divided into a head template file, a navigation template file, a content display area template file, a tail template file and other public template files according to different display areas.

Further, the static pages are divided into a home page template, a paging template and a detail page template according to different display contents.

Further, the associating module 203 includes:

the first static page generation submodule is used for replacing a placeholder in a template file according to JSON (Java Server object notation) files or cache data of service data for a home page template and a detail page template and generating a corresponding static page in real time;

the second static page generation submodule is used for configuring scheduling frequency and time according to the real-time requirement of data for the paging template to generate a corresponding static page;

and the third static page generation submodule is used for performing secondary request cache or a database on the service data with complex service and real-time change by adopting an asynchronous loading mode.

In summary, the present invention first generates a template file: generating template files for different webpages in advance, wherein the business data adopt appointed variables and occupy the place through placeholders; then generating the service data with the specified format: adding service data, automatically generating a JSON file under a specified directory or putting the JSON file into a cache besides reserving a copy of the JSON file for filing in a database, putting the service data which needs to be read or does not change frequently into the JSON file, and putting the service data which needs to be written or changes frequently into the cache; and finally, establishing association between the service data and the template file to generate a static page: for the home page template and the detail page template, replacing placeholders in the template file according to JSON files or cache data of business data, generating corresponding static pages in real time, and not accessing a database; for the paging template, the scheduling frequency and time are configured according to the real-time requirement of data, a corresponding static page is generated, and by means of scheduling of a plan task, server resources are reasonably used without influencing service access; and for the service data with complex service and real-time change, performing secondary request cache or a database in an asynchronous loading mode, and displaying the service data. The invention can reasonably utilize the resources of the server and meet the requirement of real-time change of data.

The above shows only the preferred embodiments of the present invention, and it should be noted that it is obvious to those skilled in the art that various modifications and improvements can be made without departing from the principle of the present invention, and these modifications and improvements should also be considered as the protection scope of the present invention.

8页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于区块链的网页取证处理方法、系统及设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!