O ASP gera regularmente código HTML estático, o que é muito útil para aliviar a pressão do servidor. Amigos necessitados podem consultá-lo.
Copie o código da seguinte forma:<%
'Determine se deve gerar novo HTML
if Application(cache_asptohtml_date)= then
Application.Lock
Application(cache_asptohtml_date)=now()
Application.Unlock
Call aspTohtml
Response.Redirect(index.html)
end if
if DateDiff (s, Application(cache_asptohtml_date),Now)> 100 then 'Compare o número de segundos de diferença entre o horário da última atualização e o horário
atualApplication.Lock
Application(cache_asptohtml_date)=now()
Application.UnLock
Chamada aspTohtml
Response.Redirect(index.html)
Else
Response.Redirect(index.html)
End if
'Obter a
função do diretório atual getpath
if Request.ServerVariables(SERVER_PORT)<>80 então
UserUrl = http://&Request.ServerVariables(SERVER_NAME)& : & Request.ServerVariables(SERVER_PORT)& Request.ServerVariables(URL)
else
UserUrl = http://&Request.ServerVariables(SERVER_NAME)& Request.ServerVariables(URL)
end if
getpath=left(UserUrl,InstrRev(UserUrl,/))
end function
sub aspTohtml
'---------------------------------------------------------- ------------
'Use XMLHTTP para gerar o código para a página inicial estática'Curl
é o endereço da sua página inicial, certifique-se de que seu espaço suporta FSO
'-------------------------- --------------------------------
dim read,Curl,content
Curl=getpath&home.asp
read=getHTTPPage(Curl)
if leia <> então
content = leia
Definir Fso = Server.CreateObject (Scripting.FileSystemObject)
Filen = Server.MapPath (index.html)
Definir Site_Config=FSO.CreateTextFile(Filen,true, False)
Site_Config.Write content
Site_Config.Close
Set Fso = Nothing
end if
End sub
Function getHTTPPage(url)
dim http
set http=Server.createobject(Microsoft.XMLHTTP)
Http.open GET, url,false
Http.send()
se Http.readystate<>4 então
saia da função
end if
getHTTPPage=bytesToBSTR(Http.responseBody,GB2312)
set http=nothing
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject(adodb.stream)
objstream.Type = 1
objstream.Mode =3
objstream.Abrir
objstream.Escrever corpo
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nada
End Function
%>
ASP gera regularmente páginas estáticas (HTML) 2.
Copie o código da seguinte forma:
<%
set fs= server.createobject(scripting.filesystemobject)
arquivo=server.mappath(time.txt)
conjunto txt=fs.opentextfile(file,1,true)
if not txt.atendofstream then
times=txt.ReadLine
Else
response.write <br /><!--Você descobriu que time.txt começou a ser gerado!-- >
HtmlPage = time .txt '//Nome do arquivo HTML gerado
Template = NOW()
Set FSO = Server.CreateObject (Scripting.FileSystemObject)
Set FileOut = FSO.CreateTextFile(Server.MapPath (HtmlPage))
FileOut.WriteLine Template
FileOut.Close
Set FSO = Nothing
end If
If datediff(s,times,NOW()) > 3600 Then '//O tempo desde a última atualização é maior que 3600 segundos, atualize
response.write <br /><!--Inicie a atualização após o tempo passar-->
code = Aqui está o código HTML que precisa ser gerado '//Há muitas maneiras de obter o código
'//Use FSO para gerar a página HTML
HtmlPage = index.html '//O nome do arquivo HTML gerado
Template = code
Set FSO = Server.CreateObject (Scripting. FileSystemObject)
Definir FileOut = FSO.CreateTextFile (Server.MapPath (HtmlPage))
FileOut.WriteLine Template
FileOut.Close
Definir FSO = Nada
'//Use FSO para gerar o arquivo time.txt
HtmlPage = time.txt '//Nome do arquivo HTML gerado
Template = NOW()
Set FSO = Server.CreateObject (Scripting.FileSystemObject)
Set FileOut = FSO.CreateTextFile(Server.MapPath ( HtmlPage))
FileOut.WriteLine Template
FileOut.Close
Set FSO = Nothing
Else
response.write <br /><!-- Já passou&datediff(s,times,NOW())&seconds!-->
End If
%>