Extend the default caching behavior

Configuring and using caching substantially increases the performance of your web application. When your pages are cached, on page request, they are immediately served from the cache.

However, in some cases you may want to keep most of the page cached, but change dynamically only a small portion of the page. 

EXAMPLE: Consider the case when the behavior of a widgets depends on the user input – if a user selects a checkbox on the page, the widget displays different content. If the whole page is cached, the change will not be immediately visible, because the page is served from the cache. The change will be visible only after the cache expires or is invalidated for some other reason.

In this case, you can use ASP.NET post-cache substitution. This way, you keep most of the page content cached, but substitute dynamically only the required widget.

Following are some examples you can use to modify the default cache behavior:

  • Substitute cache using a substitution widget
    Using this approach, you keep a page cached and exempt from the cache only one particular widget.
  • Override the PageRouteHandler
    Using this approach, you can create a cache that is not browser specific.

Was this article helpful?