Docsity

ASP Cache - Internet Programming - Lecture Slides, Slides of Computer Programming

Partial preview of the text

Download ASP Cache - Internet Programming - Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

ASP.NET Caching

Overview

 Caching Pages with the @ OutputCache Directive  Introduction to caching data with the Cache object

Caching an Output Page (1)

 You add the @OutputCache directive to a page with a few attributes  Duration indicates the number of seconds to cache the page  varyByParam  If set to none, cached output will not vary based on parameters  Use multiple semicolon separated parameters to create cached pages for various parameter configurations  Use * to vary cached pages for all parameter configurations docsity.com

Caching an Output Page (2)

 The caching mechanism is quite sophisticated  You can create cache dependencies to SQL tables  The cached page can be stored in the server or on the client  The HttpCachePolicy class is used to create custom cache rules

Cache an Output Page

(Advanced Features)

 It’s possible to cache parts of a page (page fragment)  Refresh an AdRotater on each postback but cache the other parts of the page

Introduction to the Cache

Object (1)

 It’s really a ‘replacement’ for the ASP.NET Application object  It’s thread safe  You to not need to explicitly lock critical code sections  It’s configurable  Cache objects can be configured to expire when you want them to  Cache object can be prioritized

Introduction to the Cache

Object (3)

 The Cache object (sort of) works in a Web garden  Each processor gets its own object  Cache objects will likely vary from one processor to the next  All the work is handled by ASP.

Important Cache Members

 The NoAbsoluteExpiration field is used to force a cached item never to expire  The NoSlidingExpiration field disables sliding expiration