In fact, the static page here is not a true sense of static, but can reach the static page parsing efficiency, but also without project testing, to share.
Copy Code code as follows:
<%
Const devjs_index= "Index.html"
Const index_default_interval=300
Dim slastupdate
' Save the last updated time with application, and make a decision on the page to generate a page every 300 seconds (5 minutes)
Slastupdate=application ("Index_last_update")
If slastupdate= "" or DateDiff ("s", Slastupdate,now ()) >index_default_interval Then
' Call MakeIndex () to generate the page and change the last update time
MakeIndex ()
Slastupdate=now ()
Application ("Index_last_update") =slastupdate
Response.Write "exceeded the default time, updated on" & Slastupdate
Else
Response.Write "read static page, updated on" & Slastupdate
End If
Response.Write Loadtextfile (Server.MapPath (Devjs_index), "GB2312")
Function MakeIndex ()
Scontent= "Call Savetextfile (Server.MapPath (Devjs_index), "GB2312", scontent)
End Function
%>
If the expiration of the update page, there is no expiration of the direct call static page, here also used two functions, together, note that the Savetextfile () is written in the overwrite way
That's the Ostream.savetofile sfilepath,2.
Copy Code code as follows:
<%
Function Loadtextfile (Sfilepath,scharset)
Dim Ostream
Set ostream=server.createobject ("ADODB. Stream ")
ostream.type=2
Ostream.mode=3
Ostream.open
Ostream.charset=scharset
Ostream.position=ostream.size
Ostream.loadfromfile Sfilepath
Loadtextfile=ostream.readtext
Ostream.close
Set ostream=nothing
End Function
Function Savetextfile (sfilepath,scharset,outstring)
Savefile=false
Dim Ostream
Set ostream = Server.CreateObject ("ADODB. Stream ")
ostream.type=2
Ostream.mode=3
Ostream.open
Ostream.charset=scharset
Ostream.writetext = outstring
Ostream.savetofile sfilepath,2
Ostream.close
Set ostream = Nothing
Savetextfile=true
End Function
%>
This is more convenient than caching, but also directly more! In fact, there are many things you can do in MakeIndex (), such as reading template files to replace them.