Programming Microsoft ASP.NET 2.0 Core Reference

 

The ability to store in memory chunks of frequently accessed data becomes a winning factor in the building of scalable Web applications that handle significant volumes of data. Instead of continuously connecting to the database server, locking records, and consuming one of the available connection channels, you can simply read the results needed from some block of memory. This scenario delineates caching as an asset for any application. Well, not just any, as we discussed but certainly for many.

Caching is rather a double-edged sword, and if abused or misused, it can easily morph into an insidious weakness. This typically happens when the quantity of memory-held information grows uncontrolled and beyond a reasonable threshold. Aside from the performance repercussions, the theoretical possibility that the data stored in the cache can grow uncontrolled also opens up security concerns. A denial-of-service (DoS) attack, in fact, might succeed in flooding the Web server's memory with useless data if the caching subsystem is not well designed.

Caching is mostly about memory. In the short run, you can perhaps even find that some good caching improves the overall performance enough to appease your customer or your boss. I'm not at all claiming that caching can fix design holes, but caching can sometimes put a patch on nonoptimal performance and allow you time to rethink and refactor the application properly.

Caching is an essential feature to consider for all serious Internet applications. To build highperformance applications, a fundamental guideline is "cache as much as you can." However, be aware that there's a threshold you should never exceed. The more aggressive you are with caching, the more you should be concerned about the invisible memory threshold that suddenly turns good things into bad things.

In ASP.NET, caching comes in two complementary forms page output caching and the Cache object. The former is a relatively quick and simple approach to serve static pages bypassing the ASP.NET pipeline. The latter is the tip of a comprehensive caching API designed to let you place a caching layer inside your business or data tier.

 

Категории