Export (0) Print
Expand All
2 out of 4 rated this helpful - Rate this topic

Output Caching and Cache Profiles in SharePoint Server 2010 (ECM)

Last modified: September 27, 2010

Applies to: SharePoint Server 2010

In this article
Pros and Cons of Output Caching
Cache Profiles
Procedures

Microsoft SharePoint Server 2010 uses output caching technology native to ASP.NET to manage when and how page content is served. ASP.NET output caching is the foundation of the SharePoint Server 2010 caching functionality; consequently, output caching in SharePoint Server 2010 behaves similarly to output caching technology available in ASP.NET.

On a heavily accessed SharePoint Server 2010 site, caching frequently accessed pages for even a minute at a time can result in substantial throughput gains. While a page is cached by the output cache, subsequent requests for that page are served from the output page without executing the code that created it, for the specified duration of the cache.

Before choosing to use output caching to improve the performance of page rendering and page-item rendering, consider benefits and drawbacks of a potential output caching implementation. All considerations are not listed in this document, but some benefits you may want to consider include:

  • Each equivalent class of content (such as page or item within a page) receives faster response, and therefore shorter latency, after it is initially rendered.

  • Each server uses less CPU time and energy to serve the same page after the initial rendering.

  • Each data source for the rendered page can scale to serve more Web clients because of the decreased traffic flow that output caching makes possible.

  • For each page request for which an output cached version of a page is served, the server does not have to:

    • Make a round trip to the database to fetch the source code for the .aspx page and any .ascx controls on the page.

    • Reload and re-render the controls.

    • Requery any data sources that the controls rely on for data.

However, before deciding to implement output caching, you may want to consider the following concerns:

  • Output caching consumes additional memory. Each version of a page consumes memory on the Web client.

  • When used with two or more front-end Web servers, output caching may affect consistency. You can configure a cache profile not to check for updates for each request and, for example, instruct it to ignore changes to the version of the Web page in the output cache until 60 seconds after the original page is updated. If you have two front-end Web servers in your topology, depending on the load balancer used to route the user's request, a reader of site content could see inconsistency if the page is rendered by one server and then a subsequent request is routed to a second server within that 60-second window.

SharePoint Server 2010 adds a more precise mechanism for customizing output caching than those available natively in ASP.NET 2.0. SharePoint Server 2010 includes cache profiles, which are list-style cache settings that you can name and apply to pages, page items, content types, and levels of scale in your site deployment.

By using cache profiles, you can control the level of granularity applied to output caching; allow or disallow site owners and administrators to choose their own cache profiles and apply them flexibly to page layouts; and target output caching at the site-collection level, the site level, and the page layout level.

You can organize caching behavior based on a user's access rights to a site. For example, you may have three groups defined: one with full control, one with read and write rights, and one with read-only rights. Output caching renders the page the same way for users with the same rights, so you can use cache profiles to target caching to specific audience groups. In the cache profiles that SharePoint Server 2010 delivers by default, the caching system renders the page once per group of user access rights and then caches the resulting HTML stream. The next user with the same access rights gets the stream from the cache.

After you create and deploy a cache profile, any change to the cache profile immediately affects all applicable content on the site. For example, if all document library page layouts in a given site collection are initially cached for 60 seconds, and you increase that duration to 120 seconds, every document library page layout in that site collection is cached for 120 seconds, regardless of the number of document library page layouts or sites in the site collection.

You can define a cache profile by using the cache profile stored in a standard SharePoint Server 2010 list, and extend it programmatically by using a VaryByCustom handler. If you apply the cache profile to the site and page layout through the user interface, down-level propagation enforces consistency in child sites. Cache policy is secured independently from other SharePoint Server 2010 features.

Note Note

To learn more about creating cache profiles in this way, see How to: Extend Caching by Using the VaryByCustom Event Handler in SharePoint Server 2010 (ECM). It describes how to create a VaryByCustom event handler, how to modify a cache profile to include custom string parameters that are passed to VaryByCustom, and how to add required code to the global.asax file.

To enable output caching for a site collection

  1. Navigate to the root Web site of the site collection. On the Site Actions menu, click Site Settings.

  2. In the Site Collection Administration section, select Site collection output cache.

  3. To enable output caching for this site collection, select Enable output cache.

  4. Choose a cache profile for anonymous users from the Anonymous Cache Profile list. This profile is applied when anonymous users access a site in this site collection.

  5. Choose a cache profile for authenticated users from the Authenticated Cache Profile list. This profile is applied when authenticated users access a site in this site collection.

  6. Choose Page Output Cache Policy options:

    • If publishing sites can use a different output cache profile, select Publishing sites can use a different page output cache profile.

    • If page layouts can use a different output cache profile, select Page layouts can use a different page output cache profile.

  7. If you want to display additional cache information on pages in this site collection, including the date and time that page contents were last rendered, select Enable debug cache information on pages.

  8. Click OK.

To enable output caching for a site

  1. Navigate to the root Web site of the site collection. On the Site Actions menu, click Site Settings.

  2. In the Site Administration section, select Site output cache.

  3. Choose an Anonymous Cache Profile option:

    • If you want to inherit a cache profile, click Inherit.

    • If you want to choose a cache profile from those currently available, select Select a page output cache profile.

  4. If you want to apply these settings to all subsites of this root Web site, select Apply these settings to all sub-sites.

  5. Click OK.

To create a new cache profile

  1. Navigate to the root Web site of the site collection. On the Site Actions menu, click Site Settings.

  2. In the Site Collection Administration section, select Site collection cache profiles.

  3. Click New.

  4. Define and create a new cache profile.

    Table 1. Cache profile detail descriptions

    Detail

    Description

    Title

    Required. The system name of this cache profile.

    Display Name

    Populates the list of available cache profiles for site owners and page layout owners.

    Display Description

    Populates the list of available cache profiles for site owners and page layout owners.

    Perform ACL Check

    Select to ensure that all items in the cache are security trimmed.

    Enabled

    Select if you want caching to happen.

    Duration

    Number of seconds to keep the cached version available.

    Check for Changes

    Select to validate on each page request that the site has not changed and to flush the cache when the site changes.

    Clear if you want better performance. If unchecked, system does not check for updates to sites for the number of seconds specified in Duration.

    Vary by Custom Parameter

    Specify a value as described in the ASP.NET HttpCachePolicy.SetVaryByCustom method documentation.

    Vary by HTTP Header

    Specify a value as described in the ASP.NET HttpCachePolicy.VaryByHeaders property documentation.

    Vary by Query String Parameters

    Specify a value as described in the ASP.NET HttpCachePolicy.VaryByParams property documentation.

    Vary by User Rights

    Select to ensure that users must have identical effective rights on all SharePoint security scopes to see the same cached page as any other user.

    Cacheability

    Choose a value from the drop-down list. Choices include NoCache, Private, Server, ServerAndNoCache, Public, and ServerAndPrivate. To learn more, see the ASP.NET HttpCacheability enumeration topic.

    Safe for Authenticated Use

    Select only for policies that you want to allow administrators and page layout designers to apply to authenticated scenarios.

    Allow Writers to View Cached Content

    Select to bypass the default behavior of not allowing people with edit rights to cached their pages.

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.