Application state vs. Cache API

Discussion in 'ASP .Net' started by Daniel Walzenbach, Jul 10, 2004.

  1. Hi,

    I need to cache infrequently changed data used by the entire application.
    Does anybody know whether using Application state
    (Application["YourGlobalState"] = somevalue;) or the Cache API
    (Cache.Insert) is more preferable?

    Thanks a lot

    Daniel Walzenbach, Jul 10, 2004
    1. Advertisements

  2. Daniel Walzenbach

    Scott Allen Guest

    The cache object is more flexible in the long run. You can set a
    duration and a priority for the cached item, for instance.
    Scott Allen, Jul 10, 2004
    1. Advertisements

  3. The cache is good, but it is considered volatile. There is never any
    guarantee that the data is there. The item may be removed when it expires or
    some condition is met (something you explicitly set), or the runtime may
    remove the item when memory gets low. In contrast, the application variables
    are there for the duration of the applications life, unless explicitly
    removed by you and it provides methods to synchronise access to the
    varibales as well. (.Lock for example).

    - Paul Glavich
    Microsoft MVP - ASP.NET

    Paul Glavich [MVP - ASP.NET], Jul 10, 2004
  4. Hi Daniel,

    I think Scott's suggestion is reasonable since the ASP.NET's Cache Object
    not only provide the share space across the whole application scope but
    also provide many mechenism to control's lifecyle(the different kind of
    dependences). Here are some tech articles on ASP.NET caching:

    #ASP.NET Caching: Techniques and Best Practices

    #Using the ASP.NET Application Cache to Make Your Applications Scream

    #Manage Detail Pages Across Multiple Platforms with Centralized Data Caching

    Hope also helpful.


    Steven Cheng
    Microsoft Online Support

    Get Secure!
    (This posting is provided "AS IS", with no warranties, and confers no

    Get Preview at ASP.NET whidbey
    Steven Cheng[MSFT], Jul 10, 2004
  5. Thank you!


    Daniel Walzenbach, Jul 10, 2004
  6. True but as with all caching, one ALWAYS checks to see if the data is in the
    cache and if not gets fresh data. So unless connection is iffy, this really
    should be a concern.


    Harry Simpson, Aug 26, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.