다음을 통해 공유


CACHING IN SHARE POINT 2010 BEST PRACTICE

SharePoint Server 2010 provides three types of caches that help improve the speed at which Web pages load in the browser.

a. The BLOB cache.

b. The Page Output Cache.

c. The Object Cache.

Page output and object cache require that you activate the ‘SharePoint Server Publishing’ feature located in the site features of your web site.

BLOB cache:

SharePoint Server 2010 provides a disk-based cache that stores files that are used by Web pages to help them load quickly in the browser, and reduces the load on the database server when it uses those files. The BLOB cache is stored directly on the hard disk drive of a front-end Web server computer. By default, the BLOB cache is off and must be enabled to use the functionality it provides. When you enable the BLOB cache on your front-end Web server, you reduce the load on the SharePoint Server 2010 database server created by read requests from Web browsers. You enable the BLOB cache in the Web.config file of the Web application to which you want to apply it. The changes that you make to the Web.config file will be applied to all site collections within the Web application. To configure and Setup BLOB Caching read here.

Page output cache profiles:

The second caching option you have with SharePoint 2010 is ASP.net Output Cache. This is an in-memory cache that saves rendered ASPX pages. Using Output cache improves performance in two ways first it reduces the amount of SQL calls. Second it reduces workload on the WFE because pages do not need to be re-rendered. Along those lines if the pages are anonymous, then no SQL check needs to be done at all present the cached pages. Microsoft testing concluded a ninefold improvement in throughput when compared to having to render the page every time it was rendered. To configure and Setup Output Caching read here.

 Object cache

Object cache is the third caching option we have for SharePoint 2010. What Object cache does is stores metadata about SharePoint Server objects (like SPWeb, SPSite, SPList, etc.) on the WFEs. When a page is rendered, if there is data that needs to be retrieved through these objects, the SQL Server will not be hit. Features of SharePoint that uses Object cache are publishing, content query web part, navigation, search query box and metadata navigation. These features are specifically written to use the Object cache API instead of the SharePoint API directly. Developers writing custom functionality can also tap into the Object cache API. To configure and Setup Output Caching read here.

BLOB Cache

1. BLOB cache should be used when pages that are accessed frequently have JavaScript, CSS, images files, and large rich media files that can be cached on the WFEs

2. It is recommended that you not set the cache size smaller than 10 GB for BLOB Caching. When you set the cache size, make sure to specify a number large enough to provide a buffer at least 20 precent bigger than the estimated size of the content that will be stored in the cache.

3. For a publishing site for which most of the visitors are anonymous or where most of the files are static content, enable the BLOB cache for as many file types as possible.

4. For other sites that contain lots of media assets that are read-only, or where only a small percentage of the media assets are updated, enable the BLOB cache for media files only.

5. Make sure that you put the BLOB cache on a drive that has sufficient disk space available in front-end Web server which to store the cache.

6. Select a drive that will be used by as few processes as possible so that the BLOB cache process does not encounter conflicts when it tries to access the drive

7. If there is a high read to write ratio BLOB caching should be used. For instance you would want to cache a site logo that is used on every page request versus a collaboration word document that is actively updated.

8. BLOB caching is optimized for supporting large files which can significantly reduce bandwidth between the WFEs and SQL Server.

9. BLOB caching is optimized to support cache control headers so that clients can cache small files which can reduce overall number of hits to the WFEs.

10. If there is anonymous access, there can be dramatic improvements because permissions do not have to be validated for cache files.

11. Client applications that use range requests can optimize load times to access large files.

Before you enable the BLOB cache, carefully consider the scenario in which you plan to use it. If your site will be used for heavy collaboration, enabling the BLOB cache might temporarily affect the performance of your site while the files to be cached are first written to the disk. After the files have been stored in the cache, site performance will improve, so take this into consideration when you decide whether or not to enable the cache. Base your decision to enable BLOB caching on the following criteria:

· For a publishing site for which most of the visitors are anonymous or where most of the files are static content, enable the BLOB cache for as many file types as possible.

· For other sites that contain lots of media assets that are read-only, or where only a small percentage of the media assets are updated, enable the BLOB cache for media files only.

Page Output cache

1. The only catch for using Output Cache is that it can only be used in conjunction with publishing pages. It cannot be used with a collaboration site.

2. Some examples of rules that can be capture in a cache profile would be to not cache if the requestor is a user who can edit pages to ensure they see the latest version of content.

3. The cache profile also specifies rules for when a page is invalidated so that when the next request is made, it comes from the database.

4. One of the main considerations for Output cache is the memory needed to support it. For each rendered page, 2(size of the page) + 32KB is needed to store the rendered page in memory.

5. Output Cache should not be used with sites using a low read to write ratio because frequent changes to content make it hard to keep the cache fresh.

6. On multi-WFE, output caching may affect consistency.

 Object Caching

1. The object cache cannot be disabled, and there is very little that can be configured. None of the out of box settings should have to be changed. Following article was written provides some additional information on this cache: Object Cache.

2. They are normal ASP.net caching and can be a problem when Server data changes in case of multiple farm.

3. It is recommended that you not set the cache size smaller than 3 MB.

Overall for caching we should keep in mind that any data where in Read/write ratio is less we should avoid caching. Only things which is static most of the time need to be cached like images etc.

When you flush the BLOB cache, you clear the contents of the BLOB cache for a Web application. This is useful if the BLOB cache becomes out of sync with the content. For example, after you restore a content database, the BLOB cache will be out of sync with the content. To correct that situation, you must flush the BLOB cache. The following procedure describes how to flush the BLOB cache for a Web application.

Important Information on Flushing:

a. Flushing the BLOB cache for a Web application affects all site collections in the Web application.

b. You cannot use the user interface to flush the BLOB cache. Instead, you use Windows PowerShell and the SharePoint object model to complete this task.

This is the link which tells you how to flush BLOB cache

Comments

  • Anonymous
    June 11, 2013
    Hi When thinking about caching SPLists for the purposes of validation in code, do you have any thoughts on this as maybe this should be done in code say with static property objects et al.

  • Anonymous
    March 17, 2014
    Hi Guys, the Page Output cache "read more" is throwing the 404 error.

  • Anonymous
    November 18, 2014
    Great stuff. thanks for sharing the detail.

  • Anonymous
    September 09, 2015
    Thanks for Sharing the information....

  • Anonymous
    November 18, 2015
    Nice Blog .. Sharing Step by Step info .thanks...