经仔细研究发现,其实应该是触发生成,也就是每隔一段时间,有访问者时,触发生成静态页面,不过也挺实用的,起码不用每次都要手动来生成了!
<%
Dim sDate,Fso,Fout
sDate = Application("缓存名称")
If IsEmpty(sDate) Or DateDiff("d",sDate,Now())>1 Then
'当没有记录时间或记录时间与当前服务器时间不一至时生成HTML并记录下当前时间
Application.Lock
Application("缓存名称") = Now() '记录当时的时间
Application.UnLock
'生成代码开始
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
Set Fout = Fso.CreateTextFile(Server.Mappath("index.htm"))
Fout.Write "这儿写首页代码" & VbCrLf
'下面这行是引用判断用的ASP文件
Fout.Write "<script language=""JavaScript"" src=""save.asp""></script>"
Fout.Close
Set Fout = Nothing
Set Fso = Nothing
'生成代码结束
Response.Write "//生成成功!"
End If
%>