Thursday, November 8, 2007

Working with Cache in MOSS 2007

Quite often we wonder about the configuration when our web sites performance go down and our users start complaining about the slow traffic.
Let me go through a series of postings to understand and implement the caching option available in MOSS 2007.
In real scenarios we may have external-facing sites with the below types of user access:
- Available to the public with anonymous user access

- Only available to some authenticated users like the subscribers, etc.

- Available to both anonymous and authenticated users.


I’ll start with the first one, assuming that we have an open site with an anonymous access setup.
We would start by enabling the output cache for the site collection. To use this feature we need to activate "MOSS Publishing Infrastructure feature" in the site collection features if we have a Team Site. But if we have used a Publishing Portal or Collaboration Portal site template, this feature should be enabled by default.
We have the option to create our own Output Cache profile, but I would try to demonstrate by using one of the existing ones.
1. Click Site Actions->Site Settings->Modify All Site Settings
2. Click "Site Collection Output Cache Profile" under the Site Collection Administration column.

Open the Public Intranet (Purely Anonymous) list item by clicking on it to have the details of the profile visible. There are quite a few settings on this cache, but the key ones for our discussion are Checking for ACL, Vary by User Rights, Duration and Check for Changes. This cache profile is intended for the part of your web site where the content is publicly available. Therefore, the settings for checking ACL (i.e. permission) and vary by user rights are off to optimize performance. When the page is cached, all requests to that page are served from the cache. The cache expires after the specified duration (e.g. 180 seconds), and then the updated content is cached for the next set of users.

So go back to the Site Actions->Site Settings->Modify All Site Settings.
-Click "Site Collection Output Cache" under the Site Collection Administration column.
-You will see the "Site Collection Output Cache Settings" page.

-Enable the Output Cache checkbox.
-Set the anonymous cache profile to Public Internet. This will allow anonymous users to take advantage of output caching for the entire web site.
-Check the two boxes in the page output cache policy section so that you can override specific section of the sub sites or web pages later.Once you have done these steps, output caching is now enabled for the entire site collection, using the specified cache profile for anonymous user.

Note: Enabling debug cache information in the cache profile lets a comment to be left at the end of the HTML markup of the web page indicating if output caching is enabled.

Something like:

Helpful for debugging purposes, and not really mandatory.

So have this implemented and see the difference in the traffic throughput of your web site.

I'll come up with the later posts (series 2 and 3) as and when I get time. Watch out for it !!!

No comments: