Content Output Caching – Part 1

Using Output Caching helps to improve the performance of an ASP.NET MVC Application. It caches the content returned by an action method so that the same content does not need to be generated each time the same action method is invoked in the controller. 

If a page takes a lot of server-side resources to create, such as database calls, file reads, search index hits, etc., it will be a good candidate to use output caching.

EPiServer has an out-of-the-box output cache attribute, but it has some limitations, for instance, it will only work for users who are not logged in, it cannot be used on child actions, and the cached will be invalidated as soon as an editor change the content. For that reason, I decided to create my own content output cache attribute. The idea is to make coding easier.

Some possible scenarios that are supported:

  • Child Action Caching.
  • Cache only for anonymous users.
  • Vary by users, params, and cookies.
  • Cache under defined circumstances.
  • Core methods can be overridden in inherited classes.

Installation

Go to the Package Manager Console and type:

Install-Package Verndale.EPiOutputCache

Build the solution and verify that the component was added correctly in the CMS.

The Content Output Cache module allows you to enable, disable, and clear the output cache.

Make sure to set the property httpCacheExpiration in the web.config file, otherwise, the output cache module will not work. Take a look at the image below:

What’s next?

In the next section, you will learn how to work with the output cache library. Go there.

Advertisements

One thought on “Content Output Caching – Part 1

  1. Pingback: Content Output Caching – Part 2 – PowerBuilder

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s