Simple cache control plugin for EPiServer CMS

This blog post is about creating a plugin in EPiServer CMS that allows web editors to manage the cache. It’s related to my previous blog post on using fragmented caching pattern together with EPiServer CMS.

Fragmented output caching

imageThe purpose of fragmented output caching is to cache specific areas of a page and allow data such as user information, shopping carts or other personalized information to vary by user.

In my previous blog post on fragmented output caching with EPiServer CMS we added cache dependencies to the output cache using the DataFactoryCache-class. By this device the output cache was flushed when the Page Data object was removed from the cache.

If your site contains user controls that execute performance-expensive functions you may wish to enable output cache for these.

Cache plugin

Since the cached user controls depend on a page data object the cache for these are flushed when the web editor publishes a new version of the page. This behavior is acceptable until the web editor wishes to update the cache without having to publish a new version of the page each time she wishes to update the cache.

To flush the output cache all we need to do is to remove the cached page data object which the output cache depends on. Using the DataFactoryCache we can create a simple cache-plugin which does just this.

Sample code for the plugin.

Below is the code-behind for the plugin. I’ve left out the using-statements for brevity.

imageThe web editor now has a tab called “Cache” which she can use to manage the cache of the current page and all cached items that depend on it.

daniel
daniel
Developer
Recent Posts
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.

Not readable? Change text. captcha txt

Start typing and press Enter to search