怎么样把首页放入application?
index.asp是真正的首页,default.asp。
index.asp中有很多查询数据库的,首页如果我把他放在application里面10分钟更新一次,default.asp:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'got_data("http://localhost/index.asp")
if application("Last")="" then
application("Last")=now
got_data("http://localhost/index.asp")
end if
if datediff("s",application("Last"),now())>600 then
application("Last")=now
got_data("http://localhost/index.asp")
end if
sub got_data(url)
set oXMLHTTP =Server.CreateObject("Microsoft.XMLHTTP")
data_got=""
oXMLHTTP.open "GET",url, false
oXMLHTTP.send
rtstatus=oXMLHTTP.status
if rtstatus=200 then
application.Lock
application("data")=bytes2BSTR(oXMLHTTP.responsebody)
application.UnLock
else
response.Redirect "index.asp"
response.End
end if
set oXMLHTTP=nothing
end sub
Function bytes2BSTR(vIn)
Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
response.Write application("data")
crt=datediff("s",application("Last"),now())
%><!--<%="页面在"&(600-int(crt))&"秒后更新"%>-->
但是每次更新就会占很多CPU怎么办?