
February 5th, 2004, 05:16 PM
|
|
Junior Member
|
|
Join Date: Feb 2004
Location: Denmark
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Tip: Cacheing XML and XLS
Being quite new to the world of XML I have been looking all over for guidance and tutorials.
I found a little trick that I have adapted to my ASP generated webpages that I'd like to share with you and also to find out if ppl here think that I'll gain something (speed/less server load) from it.
Instead of having the server load the XML and XLS for every page it's generating, it caches them in application variables which only need to be updated when the server has been reset or when the administrator makes a 'mypage.asp?refresh=true' (after updating the contents of the XML/XLS).
Code:
<%@ Language=VBScript %>
<%
dim xml
dim xsl
if isEmpty(Application("myXML")) or Request("refresh") = "true" then
'Load from disk
set xml = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
set xsl = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
xml.load Server.MapPath(".") & "\mydata.xml"
xsl.load Server.MapPath(".") & "\mydata.xsl"
Application.Lock
set Application("myXML") = xml
set Application("myXSL") = xsl
Application.UnLock
else
'Load from cache
set xml = Application("myXML")
set xsl = Application("myXSL")
end if
%>
<HTML>
<HEAD></HEAD>
<BODY>
<%Response.write xml.transformNode(xsl)%>
</BODY>
</HTML>
|