Posts

Showing posts from October 18, 2009

Cache Management in ASP.NET

Introduction Before explaining cache management in ASP.NET, let me clarify that different people use different terms for explaining the same concept i.e. managing data. Some people refer to it as state management and some others refer to it as cache management. I love to use the term cache management, may be because I like the word "cache". But conceptually there is no difference between these two. Now let's discuss different aspects of cache management (or state management) in ASP.NET. Although cache management is not an issue in Windows applications, it has always been a challenge in the web environment. Since HTTP is a stateless protocol and a web server doesn't recognize users between different requests, it becomes very important for us to recognize a particular user between different requests and also store data so that it can be re-used between different requests. ASP.NET provides many features for storing data both in the client (browser) and the server (web

Pfz.Caching - ViewIds instead of ViewStates

Introduction This is a framework for caching serializable objects in general. It has the Cache generic class that caches any object in memory/disk. If it is no more in memory, it is read from disk. It also has a CacheDictionary that does the same, but has some optimization for small data, avoiding many "buffer files" to be generated. And, finally, the best of all: Adding the App_Browsers in your project, you can make all viewstates use this technology, so only a small ViewId is sent to the client instead of the full viewstate. Also, it deletes unused files after some time and reutilizes identical files, avoiding wasting HD space. Background I didn't really face many problems when working with the web. I started to program when computers had only 1MB or 2MB. But, I see that people in general are a bit lost on when to store the data. Documentation on ViewState and Sessions is also confusing, they look interchangeable, when they are not. I first created a caching te