Re: Using Caching properly

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Managing state is not a simple topic. There are several mechanisms to do it
(cache, session, application, cookies, hidden form fields, data stores) and
no one solution works the best in all cases.

In general, just because the .NET Garbage Collector's job is to try to free
up memory when memory is needed, shouldn't be an excuse for not writing
good, efficient code.

That said, you should not rely on client-side caching mechanisms for
application-critical data since the client has control over the data. This
is a security and a functionality issue.

When it comes to server-side caching techniques (such as using the
Application.Cache), security and overhead become the main concerns. Don't
use cache, simply because you can, use it when you don't need a long-term
storage solution, you want to reduce the complexity of your application's
logic, and the data stored in the cache is not sensitive.

With this in mind, you can use the cache for only those situations that
warrant it.

-Scott


"Chris Zopers" <test123test12@xxxxxxxxx> wrote in message
news:uY3eBdduJHA.5764@xxxxxxxxxxxxxxxxxxxxxxx
Hello,

In my ASP.NET projects I often use caching (like Cache["somename"] =
someObject).

On the internet I read different opinions on this. Some saying "use
cache in every layer and as much as possible", others saying "use cache
sparingly, because it uses up server memory".

I thought the server clears items from the cache when it needs memory,
so the memory-issue isn't really an issue, or is it?

But having said that, I often do something like:

if (Cache["somename"] == null)
{
//Add to the Cache
}

But even if the server removed the item when it needs the memory, the
item is shortly after that being cached again!

I just wonder what is a proper way to use the Cache?

Greetings,
Chris



*** Sent via Developersdex http://www.developersdex.com ***


.



Relevant Pages

  • Re: PSQL control center crashes PSQL engine.
    ... usually eek out 1.7 GB of cache, but it really depends on other usage, ... memory on the server was just above 2GB. ... Certain versions of Windows do allow a process to allocate mroe than ... If you truly want to use all the memory in your server and you have ...
    (comp.databases.btrieve)
  • Re: IA64 Linux VM performance woes
    ... the server with over 8GByte memory. ... cache memory pages. ... Linux would have kernel parameter tuning interface. ...
    (Linux-Kernel)
  • Re: OLAP Engine Cache
    ... Thanks for the info but we tried the client cache size already and didn't ... We saw some by changing the server side Memory ...
    (microsoft.public.sqlserver.olap)
  • Re: Cached memory never gets released
    ... Stock linux 2.4.26 kernel. ... Due to flash bug 3M of memory gets lost due to font memory getting lost ... The output of "free" cache number steadily grows. ... longer to exhaust all of system memory with the cache. ...
    (Linux-Kernel)
  • Re: 64-bit memory consumption
    ... CPU cores and memory keep pace with each other, ... There is time spent in GC that won't be affected only to the GC cycles, you get indirect hits in the form of poor cache coherency and cache pollution in the code that uses GC'ed memory. ... Desktop CPUs with significantly larger caches aren't there yet, and on a server, your cache is shared by multiple applications, and you can't appropriate it all for your application's purpose without affecting the rest. ...
    (borland.public.delphi.non-technical)