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 |
|
|
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.
-
Go to the home page for the top-level site in the site collection.
-
On the Site Actions menu , click Site Settings.
-
Under Site Collection Administration, click Site collection cache profiles.
-
On the Cache Profiles page, click Add New item.
-
In the Title section, type a title for the new cache profile.
-
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. -
In the Display Description section, type a description for the purpose of the cache profile.
-
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. -
In the Enabled section, select the check box to enable caching.
-
In the Duration section, type the number of seconds that the cached version will be available.
-
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. -
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.
-
In the Vary by HTTP Header section, type the custom parameter as specified by HttpCachePolicy.VaryByHeaders in ASP .NET 2.0.
-
In the Vary by Query String Parameters section, type the query parameter as specified by HttpCachePolicy.VaryByParams in ASP .NET 2.0.
-
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.
-
In the Cacheability section, select the cache type as specified by HttpCacheability in ASP .NET 2.0.
-
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.
-
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. -
Click Save.
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.
-
On the Site Actions menu , click Site Settings.
-
In the Site Collection Administration section, click Site collection output cache.
-
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. -
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. -
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.
-
-
To display additional cache information on pages in the site collection, in the Debug Cache Information section, select the Enable debug cache informationon pages check box.
This includes the date and time that the page was last rendered. -
Click OK.
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.
-
On the Site Actions menu , click Site Settings.
-
Under Site Administration, click Site output cache.
-
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.
-
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 .
-
To apply the setting s to subsites in the site collection, select the Apply these settings to all sub-sites check box.
-
Click OK .
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.
-
On the Site Actions menu , click Site Settings.
-
Under Galleries, click Master pages and page layouts.
-
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.
-
Point to the page layout again, click the arrow that appears, and then click Edit Properties.
-
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.
-
Click Save.
-
Point to the name of the page layout that you want to check in, click the arrow that appears, and then click Check In.
No comments:
Post a Comment