Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET: Where/how is web.config cached?

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?

like image 607
splattne Avatar asked Nov 08 '08 14:11

splattne


2 Answers

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.

like image 129
AnthonyWJones Avatar answered Sep 19 '22 10:09

AnthonyWJones


In ASP.NET, the <appSettings> section is cached to memory after 1st access:

  • http://msdn.microsoft.com/en-us/library/aa478432.aspx
  • http://weblogs.asp.net/stevewellens/web-config-is-cached

ASP.NET restarts the application if there are updates to the web.config file.

like image 28
victor_c Avatar answered Sep 19 '22 10:09

victor_c