Caching config section values

T

Thorsten Tarrach

Hi everyone,

I currently trying to increase the performance of my HTTP module. This
module is written entirely in C# and plugged into IIS7. In order to work the
module needs some settings from the web.config file. An instrumented run
shows that reading from the config file using a class derived from
ConfigurationSection is very slow.
So I thought about caching these values. It would appear that saving them in
a global variable is safe because the application restarts each time the
web.config file is updated.

I just want to double-check with you that this is proper procedure.

Thanks, Thorsten
 
G

Gregory A. Beamer

Hi everyone,

I currently trying to increase the performance of my HTTP module. This
module is written entirely in C# and plugged into IIS7. In order to
work the module needs some settings from the web.config file. An
instrumented run shows that reading from the config file using a class
derived from ConfigurationSection is very slow.
So I thought about caching these values. It would appear that saving
them in a global variable is safe because the application restarts
each time the web.config file is updated.

I just want to double-check with you that this is proper procedure.

I often create a Singleton class that can pull up configuration elements
when the application starts. Once it is in memory (as a static class -
Shared in VB), I can grab the instance over and over again. This
increases start up by a few seconds, maybe, but it is a one time hit
when the app starts.

In other words, you are aiming in a right direction if the consistent
pull from config is slowing your app down.

Peace and Grace,
 
T

Thorsten Tarrach

Thanks Gregory,

that's good to know.

Thorsten

Gregory A. Beamer said:
I often create a Singleton class that can pull up configuration elements
when the application starts. Once it is in memory (as a static class -
Shared in VB), I can grab the instance over and over again. This
increases start up by a few seconds, maybe, but it is a one time hit
when the app starts.

In other words, you are aiming in a right direction if the consistent
pull from config is slowing your app down.

Peace and Grace,
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top