Export (0) Print
Expand All

SPContext.UseDefaultCachePolicy property

Gets or sets a Boolean value that determines whether Microsoft SharePoint Foundation sets the HTTP cache headers on the response for an item fetched from SharePoint Foundation.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public bool UseDefaultCachePolicy { get; set; }

Property value

Type: System.Boolean
true to set the HTTP cache headers; otherwise, false.

By default, SharePoint Foundation disables caching on items such as Web Part pages. By setting this value on a request early enough in relation to ASP.NET processes (in other words, before the HttpApplication.ReleaseRequestState event occurs), you can prevent SharePoint Foundation from setting the cache headers.

In a custom application that is defined through the Windows SharePoint Services 3.0 object model, set UseDefaultCachePolicy to false to prevent SharePoint Foundation from setting the cache policy, and to implement Web controls whose control or page classes, based on user data, set the cache headers and policy for the resulting response stream. To run a custom application in Windows SharePoint Services 3.0 that is defined through the Windows SharePoint Services 2.0 object model, you can add the following line of code to accomplish the same result:

[Visual Basic]

System.Web.HttpContext.Current.Items("DisableSettingBrowserCacheHeaders") = "true"

[C#]

System.Web.HttpContext.Current.Items["DisableSettingBrowserCacheHeaders"] = "true";

Show:
© 2014 Microsoft