Groups | Blog | Home
all groups > dotnet xml > january 2006 >

dotnet xml : Howto optimize XSL transformations (reuse compilations) on a web server?


peter.fredrikson NO[at]SPAM extenda.se
1/12/2006 6:13:26 AM
Hi,

I have a web server application (C#) which I would like to speed up a
little. I would appriciate a discussion of design principles for a
specific optimization scenario described below.

My web server process every request by building a XML structure
containing both application data, data from the database (or another
system), and presentation data, describing how to present the
application data in the GUI. Then the web server transform this
XML-document to HTML with a XSL document. The XSL file actually
consists of 1 main XSL with include statements to 24 other XSL files,
so it's quite a large XSL document.

Most of the CPU time in my server is occupied by compiling the XSL
structure in every request. The compilation takes place when the Load()
method is called on an instance of the class XslCompiledTransform.

So my question is: Is there an smart way to cache the compiled version
of the XSL document on the server so I will not have to recompile it in
every request?

A little more background info/questionmarks to think about :
- I have a custom session component accessible through Web Service
calls on another server so I don't use IIS sessions.
- The solution must work in load balanced scenarios.
- I don't want the solution to block other requests by using critical
sections, or at least I want to minimize the impact of resours locking.

Any id=E9es are appreciated!
Peter
Oleg Tkachenko [MVP]
1/12/2006 6:06:08 PM
[quoted text, click to view]

Well, unfortunately XslCompiledTransform doesn't allow to persist
compilation results yet. So the only option for you is caching and
precompilation - once loaded XslCompiledTransform object is thread safe
for Transform() methods.

--
Oleg Tkachenko [XML MVP, MCAD]
AddThis Social Bookmark Button