<%@ Language=VBScript %> <% Dim CACHINGDURATION_INSECONDS CACHINGDURATION_INSECONDS = 180 'THREE minutes Dim XMLURL 'URL TO READ XMLURL = "http://YOURSITE/YOURXML.xml" '-------------------------------------------------------------------------------------------------------------- Function ReadFromXML() Dim XMLObject Set XMLObject = Server.CreateObject("Microsoft.XMLHTTP") If Isobject(XMLObject) = True then XMLObject.Open "GET", XMLURL, false XMLObject.Send ReadFromXML = XMLObject.ResponseText Else ReadFromXML = "" End If Set XMLObject = Nothing End Function Function FetchAndUpdateCache() Dim sReadValue sReadValue = ReadFromXML() If sReadValue <> "" then 'We are updating value only if we get it, if not we leave it for next update to try to fetch it Application.Lock() Application("YOURXML.Value") = ReadFromXML() Application("YOURXML.LastModified") = Now() Application.UnLock() End If End Function '-------------------------------------------------------------------------------------------------------------- If Application("YOURXML.Value") = "" Then 'Check whether the value exists, if not fetch it Call FetchAndUpdateCache() Else 'Check whether the cache out of date. If so retrieve the content from the site and store it in the cache 'The VBScript DateDiff function can be used to compare dates (s = comparisons of seconds). Ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctdatediff.asp If DateDiff("s", Application("YOURXML.LastModified"), Now()) > CACHINGDURATION_INSECONDS Then Call FetchAndUpdateCache() End If End If 'Retrieve content directly from the cache Dim sXMLValue sXMLValue = Application("YOURXML.Value") Response.Write (sXMLValue) %>