ASP는 정기적으로 정적 HTML 코드를 생성하는데, 이는 서버 부담을 완화하는 데 매우 유용합니다. 도움이 필요한 친구들이 이를 참조할 수 있습니다.
다음과 같이 코드를 복사합니다.<%
'새 HTML 생성 여부 결정
if Application(cache_asptohtml_date)= then
Application.Lock
Application(cache_asptohtml_date)=now()
Application.Unlock
aspTohtml
Response.Redirect(index.html)
호출end if
if DateDiff (s, Application(cache_asptohtml_date),Now)> 100 then '마지막 업데이트 시간과 현재 시간의 초 차이를 비교합니다
.Application.Lock
Application(cache_asptohtml_date)=now()
Application.UnLock
aspTohtml 호출
Response.Redirect(index.html)
Else
Response.Redirect(index.html)
End if
'현재 디렉터리 가져오기
함수 getpath
if Request.ServerVariables(SERVER_PORT)<>80 그런 다음
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
하위 aspTohtml
'---------------------------------- -- ----------
'XMLHTTP를 사용하여 정적 홈페이지용 코드 생성'Curl은
귀하의 홈페이지 주소입니다. 귀하의 공간이 FSO를 지원하는지 확인하세요
.'------------ --------------------------------
희미한 읽기,Curl,content
Curl=getpath&home.asp
read=getHTTPPage(Curl)
if read<> then
content=read
Set Fso = Server.CreateObject(Scripting.FileSystemObject)
Filen=Server.MapPath(index.html)
Set Site_Config=FSO.CreateTextFile(Filen,true, False)
Site_Config.Write 콘텐츠
Site_Config.Close
Set Fso = Nothing
end if
End sub
함수 getHTTPPage(url)
희미 http
set http=Server.createobject(Microsoft.XMLHTTP)
Http.open GET, url,false
Http.send()
Http.readystate<>4인 경우
함수를 종료합니다
.
getHTTPPage=bytesToBSTR(Http.responseBody,GB2312)
set http=nothing
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body,Cset)
희미 objstream
set objstream = Server.CreateObject(adodb.stream)
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write 본문
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = Nothing
End Function
%>
ASP는 정기적으로 정적 페이지(HTML)를 생성합니다. 2.
다음과 같이 코드를 복사합니다.
<%
set fs= server.createobject(scripting.filesystemobject)
파일=server.mappath(time.txt)
세트 txt=fs.opentextfile(file,1,true)
if not txt.atendofstream then
times=txt.ReadLine
Else
response.write <br /><!--time.txt가 생성되기 시작한 것을 확인하셨나요!-- >
HtmlPage = time .txt '//생성된 HTML 파일 이름
Template = NOW()
FSO 설정 = Server.CreateObject(Scripting.FileSystemObject)
FileOut 설정 = FSO.CreateTextFile(Server.MapPath (HtmlPage))
FileOut.WriteLine Template
FileOut.Close
Set FSO = Nothing
end If
If datediff(s,times,NOW()) > 3600 Then '//마지막 업데이트 이후 시간이 다음보다 깁니다. 3600초,
response.write 업데이트 <br /><!--시간이 지나면 업데이트 시작-->
code = 다음은 생성해야 하는 HTML 코드입니다. '//코드를 얻는 방법은 여러 가지가 있습니다.
'//FSO를 사용하여 HTML 페이지를 생성합니다.
HtmlPage = index.html '//생성된 HTML 파일 이름
Template = code
Set FSO = Server.CreateObject(Scripting.FileSystemObject)
FileOut = FSO.CreateTextFile(Server.MapPath(HtmlPage)) 설정
FileOut.WriteLine 템플릿
FileOut.Close
FSO = 없음 설정
'//FSO를 사용하여 time.txt 파일 생성
HtmlPage = time.txt '//생성된 HTML 파일 이름
Template = NOW()
Set FSO = Server.CreateObject(Scripting.FileSystemObject)
Set FileOut = FSO.CreateTextFile(Server.MapPath( HtmlPage))
FileOut.WriteLine 템플릿
FileOut.Close
FSO = Nothing
Else
설정 response.write <br /><!-- 날짜가 지정된 시간(s,times,NOW())&초가 지났습니다!-->
End If
%>