Class OutputCacheHandler

Handles output cache settings. Used from PageBase in WebForms and ContentOutputCacheAttribute in MVC.

Inheritance
System.Object
OutputCacheHandler
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Web
Assembly: EPiServer.dll
Version: 8.11.0
Syntax
public class OutputCacheHandler

Constructors

OutputCacheHandler()

Declaration
public OutputCacheHandler()

Methods

SetCachePolicy(IPrincipal, ContentReference, HttpContextBase, Settings, Nullable<DateTime>)

Sets the cache policy for this request based on parameters as current user and parameters.

Declaration
public virtual void SetCachePolicy(IPrincipal currentPrincipal, ContentReference currentContent, HttpContextBase httpContext, Settings configurationSettings, DateTime? contentExpiration)
Parameters
Type Name Description
System.Security.Principal.IPrincipal currentPrincipal
ContentReference currentContent
System.Web.HttpContextBase httpContext
Settings configurationSettings
System.Nullable<System.DateTime> contentExpiration
Remarks

Override this method if you wish to customize the cache policy for a page. The output cache is turned on based on the following criteria:

  1. The EPnCachePolicyTimeout in web.config is > 0.

  2. The current user must not be logged on, aka Anonymous.

  3. The request must be a GET type request. Hence, Postbacks and form postings will not be cached.

  4. The current page must be the published version (the WorkID is == 0).

    The cache parameters are fetched from web.config, more specifically the EPsCacheVaryByCustom and EPsCacheVaryByParams settings. Additionally, a dependency to the DataFactoryCache is set. When pages are changed, the cache is flushed. Cache item expiration is set to the HttpCacheExpiration setting, which is the number of seconds the item should reside in the cache, as long as the StopPublish value of the page is not less than the policy timeout (in which case, the StopPublish value is used).

UseOutputCache(IPrincipal, HttpContextBase, TimeSpan)

Decides if the output cache should be used.

Declaration
public static bool UseOutputCache(IPrincipal principal, HttpContextBase context, TimeSpan duration)
Parameters
Type Name Description
System.Security.Principal.IPrincipal principal

The current principal.

System.Web.HttpContextBase context

The current context.

System.TimeSpan duration

The duration.

Returns
Type Description
System.Boolean

ValidateOutputCache(HttpContext, Object, ref HttpValidationStatus)

Validates the output cache.

Declaration
public static void ValidateOutputCache(HttpContext context, object data, ref HttpValidationStatus validationStatus)
Parameters
Type Name Description
System.Web.HttpContext context

The context.

System.Object data

The data.

System.Web.HttpValidationStatus validationStatus

The validation status.

Extension Methods