So how do you get around this bottleneck? Caching! Thankfully, SharePoint has advanced and granular configuration settings that give site administrators complete control over the level and type of caching available to publishing sites. SharePoint provides two types of caching mechanisms:
Page output caching The process of persisting the compiled page in memory on the SharePoint server, eliminating the need to go back to the database for any subsequent requests for the same page.
In a publishing site, cache settings are defined in profiles. These profiles are then available to the entire site collection, but each site can either inherit the cache configuration of the parent site or override the parent and define its own profiles.
The cache profile administration interface is available by clicking the Site Collection Cache Profiles link under the Site Collection Administration column from the site collection's Site Settings page. When a publishing site is created, the following four profiles are created by default:
Disabled This profile disables caching.
Public Internet (Purely Anonymous) This profile is configured to do no authentication checks and will be the fastest option; However, it should be used only when it's acceptable that everyone can view the same page.
Extranet (Published Site) This profile is configured to cache only major versions of pages and always check permissions when content is requested.
Intranet (Collaboration Site) This profile is configured to always check permissions when content is requested and cache major as well as minor versions of pages.
To create a new profile, click the New button on the list toolbar. As you can see in Figure 11-9, you have plenty of configuration options when creating a policy. Using these options, you can specify whether you want to check for permissions on each object request, choose from numerous Vary By options (custom parameter, HTTP header, query string parameters, and rights), specify whether users with Edit rights can view the items in cache, or specify whether the page is always pulled from the database and bypasses cache. The options aren't explained in detail here because a good description is listed with each field.
Figure 11-9: Cache Profile creation page
Page output caching in SharePoint is similar to ASP.NET 2.0 output caching. Essentially, this edge form of caching enables Web front-end (WFE) servers to store the rendered output of the controls on a page and persist them in memory. When page output caching is enabled, the following occurs:
When a page is requested, SharePoint retrieves all necessary information from the database and compiles the page, storing the resulting objects in memory.
The next time the page is requested, SharePoint checks to see whether the page exists in memory. If it does, SharePoint retrieves the objects from cache and uses them in rendering the response to the requester. If the objects aren't in memory, it repeats the first step.
After a specified time has elapsed (configurable within the cache policy), the objects in cache are invalidated and purged. This feature prevents any stale information from being returned to the users.
To enable page output caching for a publishing site, complete the following steps:
Click the Site Actions menu, select Site Settings and then select Modify All Site Settings.
Under the Site Collection Administration column, click the Site Collection Output Cache link. If output caching is not enabled, you'll see a single check box to enable the cache. Selecting this check box refreshes the page, yielding additional configuration settings. As shown in Figure 11-10, you'll see that you can select a cache profile, created earlier, as the anonymous and authenticated profile. You can also optionally specify different policies for page layout designers. These options can be helpful because your designers can always be sure they are seeing their latest changes and not some cached changes from before.
Figure 11-10: Site Collection Output Cache Settings page
SharePoint also gives site administrators the ability to specify how many objects are stored in cache, as well as forcing a flush of the object cache on a server-by-server basis or across the entire farm. These actions can be performed from the Object Cache Settings page, which is available via the Site Collection Object Cache Settings link on the Site Settings page under the Site Collection Administration column.
Enabling disk caching for a publishing site is very simple even though there is no browser UI as with page output caching. To enable disk-based caching:, open the publishing site's web.config file located in the Web Application's root directory and search for the <blobcache> node. Using the attributes in this node, you can turn on disk caching on the WFE (attribute: enabled), specify the location where files will be persisted (attribute: location), specify the type of files that will be persisted as a regular expression (attribute: path), and specify the maximum size the disk cache can reach in GB (attribute: maxSize).
Although there is no browser UI provided to save the disk caching settings, you can use the same administration page you used for the page output cache to flush the disk based cache: the Site Collection Object Cache Settings link on the Site Settings page under the Site Collection Administration column.