XMLDocument.Load vs Session

G

Guest

Hi

I'm overloading the onInit event in my custom page class and checking the requested Id in the Url is present in my XML file and also checking a couple of attributes for that Id. I'm using the XMLDocument.Load method and the SelectSingleNode method to check for my Id. I'm wondering whether it would be better to store the XML document in the session state rather than use the load method each time? The XML file that is used could change at any time so it will not always be possible to read from the session, sometimes I will need to repopulate the session first by using the load method. I'm not sure what the overhead with the load method is though

Any one got any ideas suggestions? FYI the xml file is approx 80KB
 
H

Hans Kesting

Neil said:
Hi,

I'm overloading the onInit event in my custom page class and checking the
requested Id in the Url is present in my XML file and also checking a couple
of attributes for that Id. I'm using the XMLDocument.Load method and the
SelectSingleNode method to check for my Id. I'm wondering whether it would
be better to store the XML document in the session state rather than use the
load method each time? The XML file that is used could change at any time so
it will not always be possible to read from the session, sometimes I will
need to repopulate the session first by using the load method. I'm not sure
what the overhead with the load method is though.
Any one got any ideas suggestions? FYI the xml file is approx 80KB

A slightly different approach:
Do not store it in the session (then you would have a separate copy for
every user!)
but use "Cache". Then you have just a single copy in memory (I take it that
the file
itself is not user specific).
You also have the additional advantage that you can add a "dependency" to
the
cached object, so that, when the file is changed, the cached copy is
invalidated.

You would then do something like:
- try and read from the cache
- if not present, read from file and store in cache
You might want to add some locking to make sure only one thread at a time
reads from the file.

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top