Plan and configure caching

Caching within SharePoint 2013 is an effective mechanism for increasing the performance of page and content delivery to the requesting user. As stated earlier in this chapter, SharePoint uses a combination of three distinct technologies to deliver this enhanced performance: ASP. NET output cache, BLOB cache, and page output cache.

IMPORTANT ALTERING WEB.CONFIG DURING PRODUCTION HOURS

Some of the following configurations involve altering the web.config of a web application. When this file is saved after having been changed, it automatically recycles its associated web application, potentially disrupting service to your users. It is advisable to make these configuration changes after hours.

Planning and configuring the ASP.Net output cache

The output cache present in SharePoint 2013 stores several different versions of a rendered page; these versions are permissions-dependent, based on the permissions level of the person who is attempting to view the page. Settings for this cache can be configured at the site collection and site levels, and also configured for page layouts. Additionally, the web.config for a web application can be altered with the output cache profile settings. These settings will then override any settings made at the site collection level (or below).

Cache profiles

Prior to enabling the page output cache, you can review the site collection cache profiles that will be used in the output cache in the site settings of your site collection:

1. In Site Settings, select the Site Collection Administration section; under Site Collection, select Cache Profiles.

2. Four profiles exist by default (see Figure 1):

image

FIGURE 1 Output cache profiles

A. Disabled Caching is not enabled

B. Public Internet (Purely Anonymous) Optimized for sites that serve the same content to all users with no authentication check

C. Extranet (Published Site) Optimized for a public extranet in which no authoring takes place and no web parts are changed by the users

D. Intranet (Collaboration Site) Optimized for collaboration sites (authoring, customization, and other write-intensive operations take place)

3. You can also create a new cache profile if none of these suits your needs.

Enabling the page output cache (web application level)

Enabling the page output cache at the web application level overrides all other page output cache settings at the site collection, site, or page layout levels.

To enable the page output cache:

1. Open Internet Information Services (IIS) Manager.

2. Select the web site that you want to configure (see Figure 2).

image

FIGURE 2 Explore virtual directory in IIS Manager.

3. Select the web.config and then open with the editor of your choice (see Figure 3).

image

FIGURE 3 Editing web.config

4. Search for the OutputCache Profiles XML entry:

<OutputCacheProfiles useCacheProfileOverrides="false" varyByHeader="" varyByParam="*" varyByCustom="" varyByRights="true" cacheForEditRights="false" />

5. Change the useCacheProfileOverrides attribute from False to True.

6. Save and close the web.config file.

REAL WORLD CHANGING WEB.CONFIG FOR PAGE OUTPUT CACHE

Although setting the page output cache at the web application level is highly effective, changes made at this level have to be made on the web.config files of each web tier server. Unless there is a compelling reason not to, it is recommended to enable configuration of the page output cache at the site collection level, which requires no system outage for additional changes.

Enabling the page output cache (site collection level)

Enabling the page output cache within a publishing site collection is done within the Site Collection Administration menu.

1. In Site Settings, select the Site Collection Administration section and then select Site Collection Output Cache.

2. In the Output Cache section, choose to enable or disable the output cache.

3. In the Default Page Output Cache Profile section, you get the opportunity to choose from the cache profiles mentioned earlier:

A. Anonymous Cache Profile: Choose from Disabled, Public Internet, Extranet, or Intranet

B. Authenticated Cache Profile: Choose from Disabled, Extranet, or Intranet

4. Page Output Cache Policy enables you to delegate control of the cache policy:

A. Whether publishing subsite owners can choose a different page output cache profile

B. Whether page layouts can use a different page output cache profile

5. Debug Cache Information (optional) enables you to enable debug cache information on pages for troubleshooting cache contents.

6. Click OK to close the settings page.

Enabling the page output cache (subsite level)

If previously delegated by the site collection administrator, page output cache settings can be configured at the subsite level from the Site Administration menu.

1. In Site Settings, select the Site Administration section and then select Site Output Cache.

2. On the Publishing Site Output Cache page, you can choose the Page Output Cache Profiles:

A. Anonymous Cache Profile can either inherit the parent site’s profile or select a profile (Disabled, Public Internet, Extranet, or Intranet)

B. Authenticated Cache Profile can either inherit the parent site’s profile or select a profile (Disabled, Extranet, or Intranet)

3. Optionally, you can select the check box to apply these settings to all subsites.

4. Click OK to close the settings page.

Enabling the page output cache by page layout

If previously delegated by the site collection administrator, page output cache settings can be configured on a per-page layout basis from the Master Pages And Page Layouts menu.

1. In Site Settings, in the Web Designer Galleries section, select the Master Pages And Page Layouts section.

2. On the Master Page Gallery page, choose a page layout and then select its drop-down menu.

3. After selecting the Edit Properties value, you are presented with the properties page. Scroll down to the bottom and you can select either or both authenticated or anonymous cache profiles.

4. On the ribbon, in the Commit section, select the Save icon to close the settings.

Planning and configuring the BLOB cache

The BLOB (or Binary Large Object) cache is used to prestage branding (*.gif, *.jpg, *.css, *.js), image, sound, video, and other files that are stored in SQL as BLOBs. This is a disk-based caching technique that stores these items on the web tier servers within your farm.

The purpose of storing these items on the web tier is to directly benefit from not having to retrieve these larger files from the content databases stored on the SQL data tier.

This caching mechanism is enabled or disabled on each web tier server on a per-web application basis:

<BlobCache location="C:\BlobCache\14" path="\.(gif|jpg|jpeg|jpe|jfif|bmp|dib|tif|tiff| themedbmp|themedcss|themedgif|themedjpg|themedpng|ico|png|wdp|hdp|css|js|asf|avi| flv|m4v|mov|mp3|mp4|mpeg|mpg|rm|rmvb|wma|wmv|ogg|ogv|oga|webm|xap)$" maxSize="10" enabled="false" />

There are a few settings in this piece of XML that are of interest:

  • The BLOB cache location is not a typo; it is stored in “C:\BlobCache\14” by default. Although both the location and file folder details can be changed, the change should be uniform on all web tier servers.
  • Path does not indicate the path on the file system, but instead the types of files (BLOB) that can be stored on the file system.
  • The maxSize entry indicates the size in gigabytes (GB) for the BLOB cache; any changes to this value should be made uniformly on all web tier servers.
  • The maxSize value should never be less than 10 GB, but can (and should) be grown to roughly 20 percent bigger than the expected BLOB content.
  • Changing the enabled value from false to true activates the BLOB cache.

Planning and configuring the object cache

The object cache in SharePoint 2013 is used to store objects in the memory of the web tier

SharePoint farm servers, thus reducing the amount of traffic between web tier servers and the SQL data tier. These objects—which include lists and libraries, site settings, and page layouts—are used by the publishing feature when it renders web pages on the site.

NOTE PUBLISHING FEATURE MUST BE ACTIVE

The use of the object cache requires that the publishing feature be active on your site.

After the publishing feature is enabled, so too is the object cache (using default settings).

The object cache relies on a series of settings, which can be found at Site Settings, Site Collection Administration, Site Collection Object Cache (see Figure 4).

image

FIGURE 4 Object cache settings.

1. In Site Settings, select the Site Collection Administration section and then select Site Collection Object Cache.

2. In the Object Cache Size section, specify the maximum cache size in MB (default is 100 MB). Remember that this cache space comes directly out of RAM of each server in your web tier.

3. In the Object Cache Reset section, you will normally leave these values unchecked. From here, you can not only flush the object cache of the current server (by selecting Object Cache Flush) but also that of the farm (by selecting Force All Servers In The Farm To Flush Their Object Cache).

4. In the Cross List Query Cache Changes section, you can configure the behavior of cross list queries, such as Content Query Web Parts. You have the choice of either precaching the results of such a query for a specified period of time (the default is 60 seconds) or forcing the server to check for changes every time a query is performed (which is more accurate from a results standpoint, but results in slower performance).

5. In the Cross List Query Results Multiplier section, you can choose a multiplier value ranging from 1 to 10 (where 3 is the default). This number should be increased if your site has unique security applied to many lists or libraries, but it can also be reduced if your site does not have as many unique permissions. A smaller multiplier uses less memory per query.

6. After you have made your selections, click OK.

NOTE CONTROLLING THE OBJECT CACHE WITH THE WEB.CONFIG FILE

“The object cache size can also be controlled at the web application level by altering the web.config <ObjectCache maxSize=”100” /> line.”

1. In Site Settings, select the Site Collection Administration section and then select Site Collection Object Cache.

2. In the Object Cache Size section, specify the maximum cache size in MB (default is 100 MB). Remember that this cache space comes directly out of RAM of each server in your web tier.

3. In the Object Cache Reset section, you will normally leave these values unchecked. From here, you can not only flush the object cache of the current server (by selecting Object Cache Flush) but also that of the farm (by selecting Force All Servers In The Farm To Flush Their Object Cache).

4. In the Cross List Query Cache Changes section, you can configure the behavior of cross list queries, such as Content Query Web Parts. You have the choice of either precaching the results of such a query for a specified period of time (the default is 60 seconds) or forcing the server to check for changes every time a query is performed (which is more accurate from a results standpoint, but results in slower performance).

5. In the Cross List Query Results Multiplier section, you can choose a multiplier value ranging from 1 to 10 (where 3 is the default). This number should be increased if your site has unique security applied to many lists or libraries, but it can also be reduced if your site does not have as many unique permissions. A smaller multiplier uses less memory per query.

6. After you have made your selections, click OK.