Reputation: 894
Which is better from a performance perspective?
versus
Does .NET Cache the AppSetting variables so that it is not accessing the web.config file with every use?
Upvotes: 3
Views: 864
Reputation: 161773
These two things are not comparable. appSettings
, or any other configuration settings, are for configuration settings. Application
variables are for quantities that might change during the course of the application, or are for things like tables of domain data values. These latter are things which you would not place into a configuration file, because they change rarely, and do not need to be configured.
appSettings
and everything else in a config file, is cached. The file is only read once per AppDomain, in general. In fact, when you change your web.config, it causes an AppDomain restart, mainly so that the new configuration settings can be read in.
Upvotes: 5
Reputation: 1295
appSettings are apparently not cached
EDIT: Seems both appSettings and Application variables would be the same speed then. After the initial load of course.
Upvotes: 0