Using the Cache object vs. letting .net or IIS handle it

Discussion in 'ASP .Net' started by darrel, Mar 2, 2005.

  1. darrel

    darrel Guest

    I had a conversation with a friend today.

    I'm working on a project where I have an XML file that stores the site
    structure and some page-centric variables. I have a handful of controls that
    will be reading from this XML file.

    My initial reaction was to load the XML file once, and then set it to a
    cache object, so that it's cached and only updated if the file is updated on
    the server.

    He said that was unecessary, as IIS/.net will cache frequently accessed
    files automatically for you.

    Any thoughts on that?

    -Darrel
     
    darrel, Mar 2, 2005
    #1
    1. Advertisements

  2. You had the right idea in the first place. Your friend is mixing up caching
    with caching. ;-)

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.
     
    Kevin Spencer, Mar 2, 2005
    #2
    1. Advertisements

  3. darrel

    darrel Guest

    You had the right idea in the first place. Your friend is mixing up
    caching
    Hmm...;o)

    So, what, exactly, does IIS/.net cache by default vs. what should I
    explicitly cache?

    -Darrel
     
    darrel, Mar 2, 2005
    #3
  4. darrel

    Karl Seguin Guest

    Aye...you are right..

    The O/S will likely "cahce" files that are being frequently access to savel
    save the disk I/O work...but this is really different than the type of
    caching we are talking about (I'm not aware of .Net doing any automatic
    caching btw). putting it int he Cache object specifically puts in in the
    asp.net worker processes memory space...Besides, the O/S definion of what's
    "frequent" could be like hundres of times per
    second....where as ours could be like a couple times....what good are
    friends for when you got newsgroups??

    Karl
     
    Karl Seguin, Mar 2, 2005
    #4
  5. darrel

    Karl Seguin Guest

    nothing.

    Karl
     
    Karl Seguin, Mar 2, 2005
    #5
  6. Well, you *could* argue that the compiled pages are "cached"
    server-side, since no recompilation is needed to serve them,
    but the primary benefit of caching is the substitution of database
    retrievals, contents of XML-based data, etc.

    Being able to load frequently-used data from memory,
    instead of making data calls is the main benefit.
     
    Juan T. Llibre, Mar 2, 2005
    #7
  7. darrel

    darrel Guest

    second....where as ours could be like a couple times....what good are
    ;o)

    I see...the main benefit is that I'm at the mercy of IIS or the OS itself
    deciding what to cache vs. me being able to tell .net explicitely what to
    cache.

    Thanks!

    -Darrel
     
    darrel, Mar 2, 2005
    #8
  8. darrel

    darrel Guest

    TO expand upon the question...is there an upper limit of files I shouldn't
    cache myself?

    For instance, this site will have about 10 XML files and 3 or so XSLT files.
    Is there any reason NOT to go ahead and set all of them to cache objects,
    since they'll rarely change on the server (maybe once a week or so at most)?

    -Darrel
     
    darrel, Mar 2, 2005
    #9
  9. darrel

    Joe Fallon Guest

    I thought the web.config file was automatically cached so it was only read
    once and there was no perofrmance hit when reading one of the values.
     
    Joe Fallon, Mar 3, 2005
    #10
  10. Web.config is read into memory when the application starts.

    That is slightly different than using the Cache object, though.

    You can cache pages, data fragments, all kinds of objects, etc.

    You can also set database dependency, file, key,
    time-based and expiration policies to update the cache.

    ASP.NET 2.0 introduces a concept called post-cache substitution.
    You'll love that feature ... ;-)
     
    Juan T. Llibre, Mar 3, 2005
    #11
  11. Part of the problem here may be understanding the word "cache." Caching is
    simply the process of storing data in memory somewhere. One might argue that
    creating a variable is creating a cache. In other words, the word "cache" is
    so general that unless you specify the cache you're talking about, it is
    easy to get confused about which cache one is talking about.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.
     
    Kevin Spencer, Mar 3, 2005
    #12
  12. Well, I wouldn't put it that way. Think of it this way: IIS has its
    responsibilities, which it manages all by itself. The OS has
    responsibilities which it manages all by itself. And ou have
    responsibilities which you must manage by yourself. You're not at the mercy
    of IIS; you are freed from that responsibility.

    I started out programming DOS with C. Back then, you even had to manage your
    own peripheral drivers. Believe me, you don't want to go back there!

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.
     
    Kevin Spencer, Mar 3, 2005
    #13
  13. Think of cache as a wallet full of memory (cash). As long as the wallet is
    big enough, put all the cash you need in it. After all, cash is always
    faster than credit! ;-)

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.
     
    Kevin Spencer, Mar 3, 2005
    #14
    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.