I read somewhere in the Microsoft documentation that the content of the ASP.NET's web.config is cached. If that is true, where is it cached - in memory or on disk?
And a follow-up question: are there any performance considerations I have to make, if I have to access the web.config intensively?
Its cached in memory, caching on disk doesn't make any sense, its already on disk.
First of all in ASP.NET you want to ensure you access configuration sections through the HttpContext object's GetSection
method (this uses the cached copies managed by ASP.NET).
Performance of accessing config values is a function of the internal implementation of the Section object (the object returned by GetSection). A ConfigurationSection
may simply act as wrapper for a DOM node which it may read on every request for a property. OTH it could internaly cache the value and watch for changes.
My advice would be keep your code simple and just access the values you need via GetSection
rather than attempt to hold copies of them elsewhere but by all means maintain a reference to the object returned by GetSection
for the duration of a request if you are going to fetch multiple values from it.
In ASP.NET, the <appSettings> section is cached to memory after 1st access:
ASP.NET restarts the application if there are updates to the web.config file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With