一直想写一套生成静态页面的文章系统但面对生成静态后的一些复杂数据库交互问题。又望而却步!
于是就想有没有在不耽误数据交互的情况下,而又能降低服务器负担的方法呢!
一个网站,访问量最大的莫过于首页和主栏目页了。其他的页面我可以不去想,首页和主栏目页在大流量下服务器改如何承担呢。
根据我编程2年多来的总结经验我想去了一下方法!
不生成静态页并且降低服务器负担!
复制代码代码如下:
<%@LANGUAGE="VBSCRIPT"CODEPAGE="65001"%>
<%
'读取远程文件的函数
PublicFunctionreadRemoteFile(RemoteDataUrl)
DimXMLHttp
'OnErrorResumeNext
SetXMLHttp=Server.CreateObject("Microsoft.XMLHTTP")
WithXMLHttp
.Open"Get",RemoteDataUrl,False
.Send
readRemoteFile=BytesToBstr(.responseBody,"UTF-8")
EndWith
SetXMLHttp=Nothing
EndFunction
'编码转换
FunctionBytesToBstr(body,Cset)
dimobjstream
setobjstream=Server.CreateObject("adodb.stream")
objstream.Type=1
objstream.Mode=3
objstream.Open
objstream.Writebody
objstream.Position=0
objstream.Type=2
objstream.Charset=Cset
BytesToBstr=objstream.ReadText
objstream.Close
setobjstream=nothing
EndFunction
Functiontobody()
DimdateVal
'先试图访问缓存,看有没有,或者过期没有
dateVal=Application("defaultdate")
IfdateVal=""ThendateVal=DateAdd("s",1200,Now)
IfApplication("default")<>""Then