| 
				 dim pathfilename,objstatic,temps 
        '设置缓存文件的文件名 
        pathfilename = "/html/classtree" & cstr(ChannelID) & ".html" 
        set objstatic = new StaticFile_Class 
        objstatic.Filename = pathfilename 
        '设置缓存文件有效时间,此处为10分钟,不同栏目可以设置不同值 
objstatic.refreshtime = 3600 
        '读取缓存文件 
temps = objstatic.ReadFile 
        '缓存文件存在且缓存时间有效 
if objstatic.haserror = 0 then  
            ShowEliteBlocks = temps 
        '缓存文件不存在,或缓存时间无效,需刷新 
        else 
'查询数据库并输出,下面为示意代码 
'修改原来的response.write为以下形式 
Temps = temps & "查询数据库得到的内容" 
…(代码被省略) 
'刷新缓存文件,以便下次访问 
            objstatic.writefile(strClassTree) 
ShowEliteBlocks = temps 
End if 
'清除对象 
        Set objstatic = nothing 
End function 
最后修改index.asp中的call ShowEliteBlocks(xwid)为response.write ShowEliteBlocks(xwid)。 
  
4  结语 
目前,采用ASP和VBScritp构造的动态网站还比较多。采用上述方法,通过使用静态缓存文本,可以在不影响网站动态功能的前提下,较好地改善了网站服务器的性能,而且修改原有程序的工作量比较小,修改比较容易。 			
				 |