Caching config section values

  • Thread starter Thread starter Thorsten Tarrach
  • Start date Start date
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
 
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,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
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,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top