Frog Frog Recommended: ASP improves a trick of the home page performance
Brief introduction: The home page of a website is the greatest, if your website is open, your customers will leave your website in turn. Usually we need to pass complex operation or query the database. Cake or generate a static web page to improve the performance of the web application. This time we cache the output of the home page into a string, then update, that is, taking care of performance, does not affect the timeliness of the home page. Here, some VBS Some things to define classes, Application objects, XMLHTTP objects, Adodb.Stream objects, you can check the information. It is best to let this page and the page you want to cache in a directory, you can't Show, another cached page will appear garbled, I don't know how to solve this problem, you may need to set up the coded type when response, you can try
<% Dim wawa, StarTime, EndTimeStarTime = Timer () Set wawa = new Cls_Cachewawa.Reloadtime = 0.5wawa.CacheName = "wawa" wawa.Name = "XmlInfoIndex" If wawa.ObjIsEmpty () Then CacheXmlInfoIndex () Response.Write wawa. ValueendTime = Timer () response.write "
Execution Time:" & FormatNumber ((endtime-startime) * 1000, 5) & "milliseconds."
Sub cachexmlinfoIndex () DIM bodytext, XML set XML = server.createObject ("Microsoft.xmlhttp") 'Replace the following address to your home file address, must use http: // The absolute path started, can not write relative path xml.Open "GET", "http: //onlytiancai/bak/vote/InfoIndex.asp", False xml.Send BodyText = xml.ResponseBody BodyText = BytesToBstr (BodyText, "gb2312") wawa.Value = BodyTextSet xml = NothingEnd subFunction BytesToBstr (body, Cset) dim objstream set objstream = Server.CreateObject ( "adodb.stream") objstream.Type = 1 objstream.Mode = 3 objstream.Open objstream.Write body objstream.Position = 0 objstream.Type = 2 Objstream.charset = cset bytestobstr = objstream.readtext objStream.close set objstream = Nothingend function%> <% 'below This class can be saved in a separate file, then include this page Class CLS_CACHE REM ======== ========== User description ====================================== ======== Rem = this class module is the original Network pioneer, author: Lost City prodigal son. If you use this class module, please do not remove this description. This comment does not affect the speed of the execution. = REM = Role: Cache and Cache Management Class = Rem = Public Variable: RELOADTIME Expiration Time (Mini Minute) The default value is 14400, = REM = Maxcount Cache object's maximum, exceeds the number of uses. Obsolete. The default is 300 = Rem = the total name of the Cachename Cache group, the default value is "DVBBS", if there is more than one cache group in a site, you need to change this value externally.
= Rem = Property: Name Defines Cache Object Name, write only attributes. = Rem = Property: Value Read and write cache data. = REM = function: objiisempty () determines whether the current cache has expired. = REM = Method: Delcahe (MyCahename) Manually deletes a cache object, the parameter is the name of the cache object.
= Rem =================================================== ================ Public Reloadtime, MaxCount, CacheName Private LocalCacheName, CacheData, DelCount Private Sub Class_Initialize () Reloadtime = 14400 CacheName = "Dvbbs" End Sub Private Sub SetCache (SetName, NewValue ) Application.Lock Application (SetName) = NewValue Application.unLock End Sub Private Sub makeEmpty (SetName) Application.Lock Application (SetName) = Empty Application.unLock End Sub Public Property Let Name (ByVal vNewValue) LocalCacheName = LCase (vNewValue) End Property Public Property Let Value (ByVal vNewValue) If LocalCacheName <> "" Then CacheData = Application (CacheName & "_" & LocalCacheName) If IsArray (CacheData) Then CacheData (0) = vNewValue CacheData (1) = Now () Else ReDim CacheData ( 2) CacheData (0) = vNewValue CacheData (1) = Now () End If setCache CacheName & "_" & LocalCacheName, CacheData Else Err.Raise vbObjectError 1, "DvbbsCacheServer", "please change the CacheName." End If End Property Publi c Property Get Value () If LocalCacheName <> "" Then CacheData = Application (CacheName & "_" & LocalCacheName) If IsArray (CacheData) Then Value = CacheData (0) Else Err.Raise vbObjectError 1, "DvbbsCacheServer", "The CacheData IS Empty. "