Saturday, January 18, 2014

Caching in SharePoint 2010

Caching in SharePoint 2010

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.
a.         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.



Configuring BLOB cache settings

By default, the disk-based BLOB cache is off and must be enabled on the front-end Web server if you want to use it. Use the following procedure to configure disk-based cache settings for a Web application.


Important:
Before you make changes to the web.config file, make a copy of it by using a different name (for example, web.config1), so that if a mistake is made in the file, you can restore the original file


To configure BLOB cache settings
  1. Verify that you have the following administrative credentials: You must be a member of the Administrators group on the local computer to configure the BLOB cache settings.
  2. Click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
  3. In Internet Information Services (IIS) Manager, in the Connections pane, click the plus sign (+) next to the server name that contains the Web application, and then click the plus sign next to Sites to view the Web application or applications that have been created.
  4. Right-click the name of the Web application for which you want to configure the disk-based cache, and then click Explore. Windows Explorer opens, with the directories for the selected Web application listed.
  5. Right-click web.config, and then click Open.
  6. If the Windows dialog box appears, select Select a program from a list of installed programs, and then click OK.
  7. In the Open With dialog box, click Notepad, and then click OK.
  8. In the web.config Notepad file, find the following line: <BlobCache location="" path="\.(gif|jpg|jpeg|jpe|jfif|bmp|dib|tif|tiff|ico|png|wdp|hdp|css|js|asf|avi|flv|m4v|mov|mp3|mp4|mpeg|mpg|rm|rmvb|wma|wmv)$" maxSize="10" enabled="false" />
  9. In this line, change the location attribute to specify a directory that has enough space to accommodate the cache size.

Note:
We strongly recommend that you specify a directory that is not on the same drive as where either the server operating system swap files or server log files are stored.

  1. To add or remove file types from the list of file types to be cached, for the path attribute, modify the regular expression to include or remove the appropriate file extension. If you add file extensions, make sure to separate each file type with a pipe (|), as shown in this line of code.
  2. To change the size of the cache, type a new number for maxSize. The size is expressed in gigabytes (GB), and 10 GB is the default.

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

  1. To enable the BLOB cache, change the enabled attribute, from "false" to "true".
  2. Save the Notepad file, and then close it.

Caution:
When you save a change to the web.config file, the Web application in Internet Information Services (IIS) 7.0 automatically recycles. This recycling can cause a brief interruption in service to sites contained in that Web application, and users can lose session state. For information about recycling Web applications in IIS 7.0, see IIS Process Recycling (http://go.microsoft.com/fwlink/p/?LinkId=154094).




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.
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

b.         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.


Configuring cache profile settings
Cache profile settings can be configured in the user interface at the site collection level by a site collection administrator, as well as at the Web application level by an administrator on the front-end Web server. The page output cache must be enabled at the site collection level before page output cache profiles can be configured at either the site collection level or Web application level. If page output cache profiles are enabled at the Web application level, the settings specified in Web.config will be used for all page output cache profiles, overriding any values that have been entered through the user interface at the site collection level



Note:
To use the page output cache and the associated cache profile settings, you must be using the Publishing feature on your site.

Use the following procedure to configure the cache profile settings for a Web application.

Important:
Before you make changes to the web.config file, make a copy of it by using a different name (for example, web.config1), so that if a mistake is made in the file, you can restore the original file.



To configure page output cache profile settings
  1. Verify that you have the following administrative credentials: You must be a member of the Administrators group on the local computer to configure the cache profile settings.
  2. Click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
  3. In Internet Information Services (IIS) Manager, in the Connections pane, click the plus sign (+) next to the server name that contains the Web application, and then click the plus sign next to Sites to view the Web application or applications that have been created.
  4. Right-click the name of the Web application for which you want to configure the disk-based cache, and then click Explore. Windows Explorer opens, with the directories for the selected Web application listed.
  5. Right-click web.config, and then click Open.
  6. If the Windows dialog box appears, select Select a program from a list of installed programs, and then click OK.
  7. In the Open With dialog box, click Notepad, and then click OK.
  8. In the web.config Notepad file, find the following line: <OutputCacheProfiles useCacheProfileOverrides="false" varyByHeader="" varyByParam="*"  varyByCustom="" varyByRights="true" cacheForEditRights="false" />
  9. To enable the cache profile at the Web application level, change the useCacheProfileOverrides attribute, from "false" to "true".
  10. To override the varyByHeader attribute, type a custom parameter as specified in the .NET Framework Class Library entry HttpCachePolicy.VaryByHeaders Property(http://go.microsoft.com/fwlink/p/?LinkId=164238&clcid=0x409).
  11. To override the varyByParam attribute, type a custom parameter as specified in the .NET Framework Class Library entry HttpCachePolicy.VaryByParams Property(http://go.microsoft.com/fwlink/p/?LinkId=164242&clcid=0x409).
  12. To override the varyByCustom attribute, type a custom parameter as specified in the .NET Framework Class Library entry HttpCachePolicy.SetVaryByCustom Method(http://go.microsoft.com/fwlink/p/?LinkId=164240&clcid=0x409).
  13. To override the varyByRights attribute, change the value from "true" to "false". This will remove the requirement that users must have identical effective permissions on all securable objects to see the same cached page as any other user.
  14. To override the cacheForEditRights attribute, change the cacheForEditRights attribute, from "false" to "true". This will bypass the normal behavior in which people with edit permissions have their pages cached.
  15. Save the Notepad file, and then close it.

Caution:
When you save a change to the web.config file, the Web application in Internet Information Services (IIS) 7.0 automatically recycles. This recycling can cause a brief interruption in service to sites contained in that Web application, and users can lose session state. For information about recycling Web applications in IIS 7.0, see IIS Process Recycling(http://go.microsoft.com/fwlink/p/?LinkId=154094).



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.
c.       The Object Cache

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
Configuring object cache settings

The object cache settings can be configured at the site collection level in the user interface by a site collection administrator, and is on by default. The maximum cache size can be configured at the Web application level on the front-end Web server to place a restriction on the maximum amount of memory that the cache will use for all site collections. For example, individual site collections might have the object cache set at 100 MB, while the Web application might be set at 1 GB. In this case, no more than 1 GB of memory will be used by all the caches on the server


Note:
To use the object cache, you must be using the Publishing feature on your site.

Use the following procedure to configure the object cache settings for a Web application on a front-end Web server.

Important:
Before you make changes to the web.config file, make a copy of it by using a different name (for example, web.config1), so that if a mistake is made in the file, you can restore the original file.

To configure object cache settings
  1. Verify that you have the following administrative credentials: You must be a member of the Administrators group on the local computer to configure the object cache settings.
  2. Click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
  3. In Internet Information Services (IIS) Manager, in the Connections pane, click the plus sign (+) next to the server name that contains the Web application, and then click the plus sign next to Sites to view the Web application or applications that have been created.
  4. Right-click the name of the Web application for which you want to configure the disk-based cache, and then click Explore. Windows Explorer opens, with the directories for the selected Web application listed.
  5. Right-click web.config, and then click Open.
  6. If the Windows dialog box appears, select Select a program from a list of installed programs, and then click OK.
  7. In the Open With dialog box, click Notepad, and then click OK.
  8. In the Web.config Notepad file, find the following line: <ObjectCache maxSize="100" />
  9. To change the size of the cache, type a new number for maxSize. The size is expressed in megabytes (MB), and 100 MB is the default.
  10. Save the Notepad file, and then close it.

Caution:
When you save a change to the web.config file, the Web application in Internet Information Services (IIS) 7.0 automatically recycles. This recycling can cause a brief interruption in service to sites contained in that Web application, and users can lose session state. For information about recycling Web applications in IIS 7.0, see IIS Process Recycling(http://go.microsoft.com/fwlink/p/?LinkId=154094).

References:

Link 1

Link 2

Link 3



No comments:

Post a Comment

Image noise comparison methods

 1. using reference image technique     - peak_signal_noise_ratio (PSNR)     - SSI 2. non-reference image technique     - BRISQUE python pac...