ASP.NET Web.Config ConfigurationManager.AppSettings File Caching

12,026

They are taken from memory, since the web.config is read only once when the application starts.

However, ASP.NET monitors the web.config file to detect and load changes

It is important to realize that the entire section is read, parsed, and cached the first time we retrieve a setting value. From that point forward, all requests for setting values come from an in-memory cache, so access is quite fast and doesn't incur any subsequent overhead for accessing the file or parsing the XML.

Application Configuration Files Explained in MSDN

For more info:

http://weblogs.asp.net/stevewellens/archive/2011/01/15/web-config-is-cached.aspx

Share:
12,026

Related videos on Youtube

cesaraviles
Author by

cesaraviles

I love to learn, teach, and build things.

Updated on October 10, 2022

Comments

  • cesaraviles
    cesaraviles over 1 year

    I am using ConfigurationManager.AppSettings collection to retreive configuration values from a Web.config file in an ASP.NET application. Does anyone know if values in AppSettings get cached in memory somehow or if a file read of Web.config occurs every time when retrieving a setting?

    string someValue = ConfigurationManager.AppSettings["SomeSetting"];
    

    Thanks

  • cesaraviles
    cesaraviles over 11 years
    That's what I was assuming but wanted to check. Exactly what I needed to know. Thanks.
  • Chris
    Chris about 10 years
    This article suggests caching them still speeds things up dotnetperls.com/appsettings-cache