Improve page rendering by configuring output caching

If your site receives a lot of visits, you can configure page output caching for frequently accessed pages to improve site performance.

 Note    If you want to use page output caching, the publishing feature must be enabled for your site.

In this article


About page output caching

Page output caching stores rendered output of all controls on a given page, and it also stores several different versions of this pre-rendered page. Page output cache settings can be configured at the site collection level, the site level, and for individual page layouts. The page output cache is turned off by default.

After a page is first rendered to a user in a given user class, each subsequent time that user views that page in the same class, the page loads faster because the controls on the .aspx page do not need to run again to generate the HTML. The amount of time required to render the page is reduced. The page output cache can improve server performance because it reduces server control activities and calls to the database.

Before you decide to use output caching to improve the performance of page and page-item rendering, you might want to consider the following list of potential advantages and disadvantages of output caching. The following list is not exhaustive and there may also be additional considerations.

Advantages of output caching Disadvantages of output caching
  • 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.
    • Re-query any data sources that the controls rely on for data.
  • 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, and 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.

Top of Page Top of Page

Create a new cache profile

Cache profiles describe specific cache settings for each type of page output cache. A cache profile defines the following types of cache behavior:

  • The length of time that items should be held within the cache
  • The security trimming policy
  • The expiration of settings, such as duration and changes
  • The partition of a cache based on user permission, user rights, and other custom variables.

Because a cache profile can be centrally defined for a site collection, you can update a profile in one place and the change is immediately implemented across the site collection. You must be a Site Collection Administrator to define new cache profiles.

 Note    Cache profiles determine the behavior of the page output cache for a site collection, an individual site, or a master page to which the cache profiles are applied.

  1. Go to the home page for the top-level site in the site collection.
  2. On the Site Actions menu Button image, click Site Settings.
  3. Under Site Collection Administration, click Site collection cache profiles.
  4. On the Cache Profiles page, click Add New item.
  5. In the Title section, type a title for the new cache profile.
  6. In the Display Name section, type a name for the cache profile.

    The display name appears in the list of available cache profiles for site owners and page layout owners.
  7. In the Display Description section, type a description for the purpose of the cache profile.
  8. In the Perform ACL Check section, select the check box to ensure that all items in the cache are security trimmed.

    Although you can clear the check box to provide additional speed, you should do this only for sites or page layouts that do not have information that needs to be security trimmed.
  9. In the Enabled section, select the check box to enable caching.
  10. In the Duration section, type the number of seconds that the cached version will be available.
  11. In the Check for Changes section, select the check box to validate on each page request that the site has not changed and will flush the cache on changes to the site.

    Although you can clear the check box to enhance performance, when you do this, the system does not check for updates to the site for the number of seconds specified in the Duration section. This can result in users not seeing the most current information.
  12. In the Vary by Custom Parameter section, type the custom parameter as specified by HttpCachePolicy.SetVaryByCustom in ASP.NET 2.0.

     Note    For more details about the parameters here and in the following steps, refer to the .NET Framework Class Library on MSDN.

  13. In the Vary by HTTP Header section, type the custom parameter as specified by HttpCachePolicy.VaryByHeaders in ASP .NET 2.0.
  14. In the Vary by Query String Parameters section, type the query parameter as specified by HttpCachePolicy.VaryByParams in ASP .NET 2.0.
  15. In the Vary by User Rights section, select the check box to ensure that users must have identical effective permissions on all securable objects to see the same cached page as any other user.
  16. In the Cacheability section, select the cache type as specified by HttpCacheability in ASP .NET 2.0.
  17. In the Safe for Authenticated Use section, select the check box for the policies that you want to allow administrators and page layout designers to apply to authenticated scenarios.
  18. In the Allow writers to view cached content section, select the check box to bypass the normal behavior in which people with edit permissions have their pages cached.

    Enable this behavior in scenarios in which you know that the page will be published, but will not have content that might be checked out or exist in draft form, such as a Content Query Web Part.
  19. Click Save.

Top of Page Top of Page

Configure page output cache settings for a site collection

You must be a Site Collection Administrator to configure page output cache settings for a site collection.

  1. On the Site Actions menu Button image, click Site Settings.
  2. In the Site Collection Administration section, click Site collection output cache.
  3. To enable output caching in the site collection, click the Enable output cache check box.

    A list of cache settings is displayed on the page.
  4. In the Default Page Output Cache Profile section, in the Anonymous Cache Profile list, select the cache profile to use for anonymous users, and then, in the Authenticated Cache Profile list, select the cache profile to use for authenticated users.

    This optimizes the use of the cache based on the authentication methods allowed on the site. Page output cache profiles specifically affect portal publishing pages.
  5. In the Page Output Cache Policy section, do one or more of the following:
  • To set a different cache profile for publishing sites, select the Publishing sites can use a different page output cache profile check box.
  • To set a different cache profile for page layouts, select the Page layouts can use a different page output cache profile check box.
  1. To display additional cache information on pages in the site collection, in the Debug Cache Information section, select the Enable debug cache information on pages check box.

    This includes the date and time that the page was last rendered.
  2. Click OK.

Top of Page Top of Page

Configure page output cache settings at the site level

Use the following steps to configure the page output cache settings for a publishing site. You must have the Full Control permission for a site to configure page output cache settings for a site.

  1. On the Site Actions menu Button image, click Site Settings.
  2. Under Site Administration, click Site output cache.
  3. Under Anonymous Cache Profile, do one of the following:
  • To inherit the site-wide anonymous profile that you configured on the Site Collection Output Cache Settings page, select Inherit the profile <profile name>.
  • To select a different anonymous cache profile for a page, click Select a page output cache profile.
  1. Under Authenticated Cache Profile, do one of the following:
  • To inherit the site-wide authenticated profile that was configured on the Site Collection Output Cache Settings page, select Inherit the profile <profile name>.
  • To select a different authenticated cache profile for a page, select Select a page output cache profile.
  1. To apply the settings to subsites in the site collection, select the Apply these settings to all sub-sites check box.
  2. Click OK.

Top of Page Top of Page

Configure page output cache settings for page layouts

Use the following steps to configure the authenticated and anonymous cache profiles that will be used in each page layout. You must be at least a Designer for a site to configure output caching for page layouts.

  1. On the Site Actions menu Button image, click Site Settings.
  2. Under Galleries, click Master pages and page layouts.
  3. On the Master Page Gallery page, point to the name of the page layout to which you want to apply a cache profile, click the arrow that appears, and then click Check Out.
  4. Point to the page layout again, click the arrow that appears, and then click Edit Properties.
  5. Do one or both of the following:
  • In the Authenticated Cache Profile box, select the authenticated cache profile that you want to apply to the page layout.
  • In the Anonymous Cache Profile box, select the anonymous cache profile that you want to apply to the page layout.

 Note   On some sites, you may have you may have to select Page Layout from the Content Type section before you will see the cache profile options.

  1. Click Save.
  2. Point to the name of the page layout that you want to check in, click the arrow that appears, and then click Check In.

Top of Page Top of Page

 
 
Applies to:
SharePoint Online for enterprises, SharePoint Server 2010