Reputation: 105029
I have custom configuration section within web.config file. I'm lingering between:
What do you think about auto file (on open) caching...
Upvotes: 1
Views: 1728
Reputation: 13266
Write a custom configuration section and use ConfigurationManager.GetSection
.NET Takes care of caching this and invalidates whenever the web.config file is changed.
Upvotes: 8
Reputation: 21178
Reading values from web.config is very, very fast. The ConfigurationManager is highly optimized for the purpose. So fast that there is almost no gain over storing the value in Session, Cache, etc. However, if you store a setting in web.config changing the value restarts the app but the old cached value would still be present if you used the Cache ... so don't. Simply read the value from web.config when you need it; on a standard laptop I'm able to read a web.config setting over 600,000 times a second without issue.
Upvotes: 3
Reputation: 7432
AFAIK, config files are already cached in memory as long when the System.Configuration.ConfigurationManager is used.
Just one reason why changing a web.config/app.config requires an app restart to pick up changes
Upvotes: 2