开发者

How often is the Application store refreshed in an ASP.Net Website?

A website that I'm working on is making extensive use of the HttpContext.Current.Application store to cache lookup data from the database. (This isn't a lot of data - just simple things that are used in drop down lists etc..)

A few开发者_开发技巧 questions about this approach:

  • Does this store have a lifetime (in the same way that a user's session will time-out after 20 minutes, does the application store timeout)?

  • Do events in IIS or events in the same App Domain as the website cause the Application store to refresh? (I understand that changing a value in the web.config file causes the store to be re-created.. are there other things that do this?)

  • Is there a better way to do this?


Web.config causes the application to restart, and it is that action which is clearing out HttpContext.Current.Application.

Anything that restarts the application, touching web.config, manually doing it in IIS, having the application pool recycled by IIS will "clear" that data.

With that in mind it is still the most pernament in-memory store available, so if you need something more pernament you will have to persist your data to disk or to a database somewhere.

You probably don't really need to use it though (we rarely do), usually the best tactic is to use the application cache and rebuild resources as required. As long as your server isnt under high memory stress then cache will not be dropped either (unelss an expiry is set).


My understanding this is available for the application lifetime, or until the application pool is reset.

There is a good article here on all the various reasons the application/session pool in IIS would be recycled.

There are settings in both IIS and also web.config which can change the behavior of the application store availability.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜