怎么样把首页放入application?

lein11 2005-04-19 10:29:52
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怎么办?
...全文
84 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lein11 2005-05-30
  • 打赏
  • 举报
回复
顶一下.
zhangfeng1133 2005-05-23
  • 打赏
  • 举报
回复
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

你试一试把这个函数换掉,试一试,
听说用byte操作,速度很快,我不知道放哪里了,不过我觉的不会占太大资源吧
或者,你写成 **.html 模板,向动网一样啊,{$$ddd}
有数据的地方 replace

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧