With the development of Internet, the application of Web database is more and more, and the user's speed of accessing Web Database page is more and more high. The speed of accessing a Web page depends on the speed of the network, the performance of the server on the Web page, and the design of the Web page itself. This paper introduces a method to optimize the Web database page based on the author's years of experience development.
Solution principle
When a user accesses a static Web page, the Web server simply passes the page back to the user's browser, which is interpreted by the browser, and when the user accesses a "dynamic" Web page (with a server-side executor), the Web server needs to explain the execution of the page first. The server-side execution code that is embedded in the page is executed on the server side, and the execution results form a "static" Web page that is passed back to the user's browser and interpreted by the browser.
In the Web database application system, when the user accesses the Web database page, the Web server needs to exchange information with the database server, read the data dynamically from the database and form a "static" Web page to return to the user's browser, and then explain the execution by the browser.
Based on the above process of Web page execution, if the "read data from the database" is executed only once and a "static" HTML snippet is inserted, inserting the code into a page that needs to be read dynamically from the database can reduce the cost of accessing the database, thereby increasing the speed of accessing the page, The principle is similar to a compilation of a program, multiple executions.
Programming instances
The following take the train booking system as an example to illustrate the specific implementation of the method. The data of station name, train number, station and parking time are designed and stored in the database in the railway reservation system. Due to the increase or decrease of the train and station name, parking time changes and other information will not change frequently, with relative stability, so you can change the data needs of the system administrator at a time to execute a piece of code, from the database to extract data and generate a number of HTML code "static" reference files for the need for station name, train, docking station , parking time for each web page reference. Only when the next railway system adjusts the time, the number of trips and other information, the system administrator is necessary to modify the data in the database, regenerate and overwrite the original HTML code "static" reference file, and the "Static" code to refer to the various web pages without any modification.
The following is an example of "station name", which describes the generation of "static" code and how each Web page refers to this "static" code. Set the system to use Access database Train.mdb, table name is Tab_train, "Station name" field is stations. First read the "station name" from the database and generate the "static" HTML code of the ASP program, and then save the generated "static" code in the file Stations.inc.
/*make_stations.asp*/
<%
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
FilePath = Server.MapPath ("Station.inc")
Set file = fso. CreateTextFile (FilePath)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.