Data and Output Caching






Summary

This chapter has been all about performance, even though the topic is actually caching, because performance is the ultimate goal. You've seen a number of techniques for storing and accessing data, and you've seen common patterns in use.

We started with the Application, Session HttpContext, and ViewState, seeing their limitations, namely, that they are more suited to small amounts of data. We then moved on to output caching, which stores the HTML output by the processed page. This can provide a huge improvement in performance, especially when the page contains data sourced from a database or a file. Output caching can be finely controlled by caching pages, or parts of pages, using control caching or post-cache substitution. This allows you to only cache the parts of the page that are dependent on slow data.

To ensure that the data you cache is refreshed when changed, you can use cache invalidation by way of SQL Dependencies. These add items to the cache, including the output cache, and place a dependency upon them, allowing the item to be evicted from the cache when the data changes. This provides the best of both worlds: cached pages and up-to-date data.

Finally, you saw the Cache API, which is the underlying architecture behind much of the caching in the rest of the chapter. You saw that you can access the cache programmatically and set dependencies to ensure cached items are evicted when the data changes or when a certain time limit is up.

All of these techniques provide a simple way for you to improve the performance of your Web sites. Now it's time to look at another data topic in detailXML.



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows