mdo:setup-output-cache(seconds, location)

Setups caching for complete ASP.NET page
Sample:


<xsl:execute select="mdo:setup-output-cache(10, 'Server')" />

Setting up output caching

1. Setting up web.config

You have to add something like that into your web.config


  <system.web>
    <caching>
      <outputCache enableOutputCache = "true" enableFragmentCache = "true" sendCacheControlHeader = "true" />
    </caching>
  <system.web>

2. Setting up Global.asax

XsltDb output caching requires some code to be added to your Global.asax file


<%@ Application Language="C#" Inherits="DotNetNuke.Common.Global" %>

<script runat="server">
public override string GetVaryByCustomString(HttpContext context, string arg)
{
    if (arg == "XsltDbStar")
    {
        StringBuilder sb = new StringBuilder();
        sb.Append(HttpContext.Current.Request.Form.ToString());
        sb.Append(HttpContext.Current.Request.Url.AbsoluteUri);
        HttpCookie c = HttpContext.Current.Request.Cookies[".DOTNETNUKE"];
        if (c != null)
            sb.Append("user-is-logged");
        string language = HttpContext.Current.Request["language"];
        if ( string.IsNullOrEmpty(language) )
        {
            c = HttpContext.Current.Request.Cookies["language"];
            if (c != null)
                language = c.Value;
        }
        if ( !string.IsNullOrEmpty(language) )
                sb.Append(language);

        return sb.ToString();
    }
    return base.GetVaryByCustomString(context, arg);
}
</script>

Note, that authentication cookie name may differ from .DOTNETNUKE, you must check web.config and use correct one.

Last edited Mar 5, 2011 at 1:32 PM by findy, version 1

Comments

No comments yet.