ASP method to generate static web pages
As the number of website visits increases, every time you read from the database, it comes at the cost of efficiency. Many people who use ACCESS as database will have a deeper understanding. Static pages will also be given priority when adding them to search. A popular practice on the Internet is to write the data source code into the database and then read it from the database to generate static surfaces, which invisibly increases the database. Generating static pages directly from existing ASP pages will save a lot.
The following example is to generate the three dynamic pages of index.asp?id=1/index.asp?id=2/index.asp?id=3/, respectively, and generate ndex1.htm, index2.htm, and index3.htm in the root directory:
<%
dimstrUrl,Item_Classid,id,FileName,FilePath,Do_Url,Html_Temp
Html_Temp="<UL>"
Fori=1To3
Html_Temp=Html_Temp&"<LI>"
Item_Classid=i
FileName="Index"&Item_Classid&".htm"
FilePath=Server.MapPath("/")&"/"&FileName
Html_Temp=Html_Temp&FilePath&"</LI>"
Do_Url="http://"
Do_Url=Do_Url&Request.ServerVariables("SERVER_NAME")&"/main/index.asp"
Do_Url=Do_Url&"?Item_Classid="&Item_Classid
strUrl=Do_Url
dimobjXmlHttp
setobjXmlHttp=Server.CreateObject("Microsoft.XMLHTTP")
objXmlHttp.open"GET",strUrl,false
objXmlHttp.send()
DimbinFileData
binFileData=objXmlHttp.responseBody
DimobjAdoStream
setobjAdoStream=Server.CreateObject("ADODB.Stream")
objAdoStream.Type=1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFileFilePath,2
objAdoStream.Close()
Next
Html_Temp=Html_Temp&"<UL>"
%>
<%
Response.Write("File generated successfully:")
Response.Write("<BR>")
Response.WriteHtml_Temp
%>
How to generate static web pages in PHP
I saw many friends posting in various places about how to generate static article systems for PHP. I have done such a system before, so I would like to share some opinions for your reference. OK, let’s review some basic concepts first.
1. PHP scripts and dynamic pages.
PHP script is a server-side scripting program that can be mixed with HTML files through embedding and other methods, or can be used in the form of class, function encapsulation, etc. to process user requests in the form of templates. In any way, the basic principle is like this. The client makes a request to a certain page ------> WEB server introduces the specified corresponding script for processing ------> The script is loaded into the server ------> The PHP parser specified by the server parses the script to form an HTML language form -----> The parsed HTML statement is passed back to the browser in a package form. It is not difficult to see from this that after the page is sent to the browser, PHP no longer exists and has been converted and parsed into HTML statements. The client request is a dynamic file. In fact, no real file exists there. It is parsed by PHP into the corresponding page and sent back to the browser. This way of page processing is called "dynamic page".