SharePoint Output Cache – Some important points
avatar

The output cache stores the rendered output of a page and therefore leads to faster page loads and a better end user experience. At this point It’s important to mention, that it can only be used in site collections, in which the publishing infrastructure has been enabled.

There’s a lot of documentation out there about the enabling and the configuration of the output cache, so I won’t talk about this in detail. In this blog post I only want to talk about the following points:

  • Configuration of the output cache for specific page layouts
  • Verification whether the output cache is working or not
  • The “Allow writers to view cached content” setting that can be found in the configuration of the output cache profiles

Configuration of the output cache for specific page layouts

When you read the documentation or are already configuring the output cache you’ll observe that there’s an area called “Page Output Cache Profile” in the “Output Cache” settings of the site collection. One of the configuration options that can be found there is called “Page layouts can use a different page output cache profile”.

image

By activating this option, you get the chance to assign different output cache profiles to different page layouts, which makes sense for search result page layouts for example.

The important point that is sometimes misunderstood is, that this option is not mandatory. When you only want one output cache profile for every page layout in the site collection it’s enough to just enable the output cache and choose the desired output cache profile in the “Authenticated Cache Profile” section.

image

Verification whether the output cache is working

If you ever configured the output cache, you’ll probably agree with me, that it’s pretty straight forward. The harder part is, to verify if the output cache is working like desired.

I stumbled across a very good article called “Measuring the Output Cache on SharePoint 2010”, in which the author describes how to verify this with the help of the output cache performance counters.

I don’t want to repeat everything that can be found in that article, I just want to describe how the single performance counters behave with the output cache disabled/enabled.

The performance counters I like to focus on are Output cache entries, Output cache hit ratio, Output cache hits and Output cache misses

For all performance counters I changed the scale from 0.1 to 1.0 to analyse the values easier.

image

With the output cache disabled (or not working), the following values can be found for the single counters after the first load of a page (only applies if there’s no other user or service hitting the cache):

Output cache entries = 0
Output cache hit ratio = 0
Output cache hits = 0
Output cache misses = 1

After the second load of the page the values for the single counters look like this:

Output cache entries = 0
Output cache hit ratio = 0
Output cache hits = 0
Output cache misses = 2

So the only counter that increases is the “Output cache misses” counter. This totally makes sense as nothing gets cached and therefore there can’t be any cache entries, cache hits as well as a cache hit ratio.

With the output cache enabled and working, the following values can be found for the single counters after the first load of a page:

Output cache entries = 1
Output cache hit ratio = 0
Output cache hits = 0
Output cache misses = 0

The only counter that increases is the “Output cache entries” counter. As this counter shows how many entries are stored in the output cache this also makes sense. There cannot be any “Output cache hits” because there’s nothing in the cache.

After the second load of the page the values for the performance counters look like this

Output cache entries = 1
Output cache hit ratio = 50
Output cache hits = 1
Output cache misses = 0

With the second load of the page, the “Output cache entries” counter doesn’t increase, because the objects are already cached. At this point you can witness, that the “Output cache hits” counter increases, because cached objects have been loaded.

Allow writers to view cached content

When you configured the output cache correctly, but the performance counters indicate, that the output cache is not working, this might not mean that there’s a real problem. When I configured the output cache for the first time and tested it afterwards, nothing has been cached.

I enabled the “Debug Cache Information” option as well as verbose logging for the “Publishing” and the “Publishing Cache”.

image

In the ULS logs I found the following message “User can view an unpublished version of the current page”. After some research I realized that there’s no problem with the output cache in general, but a problem with my scenario.

Nothing was cached for the user with which I was testing the functionality, because of a setting that can be found in the output cache profiles. This setting is called “Allow writers to view cached content” and is disabled by default in all profiles.

image

From the description of the setting you can gather the information, that pages are not cached for users that have edit permissions. As my user had full control permissions on all site collections nothing was cached. After I enabled the setting the output cached worked as desired!

Here’s another great resource concerning the troubleshooting of the output cache, that helped me a lot: When cache output caching does not output

Schreibe einen Kommentar