Output Caching Broken

  • Updated

Starting around version 8.6, output caching stopped working in some cases. Microsoft released a patch KB2836939 that prevented the output cache from working in Ektron.
Removing this patch is not a valid workaround.
You can add the code below to the global.asax file to fix the output cache function.

Info about the Microsoft Patch:  http://support.microsoft.com/kb/2836939

Add the following code into your existing Global.asax file, or create a new file and insert this code in it.

<%@ Application Language="C#" %>
<script runat="server">

     void Application_PostRequestHandlerExecute(object sender, EventArgs e)
     {
          Dictionary<String, HttpCookie> cookieCollection = new Dictionary<string, HttpCookie>();
          for (int i = HttpContext.Current.Response.Cookies.Count - 1; i >= 0; i--)
          {
               HttpCookie c = HttpContext.Current.Response.Cookies.Get(i);
               if (!cookieCollection.ContainsKey(c.Name))
               {
                    cookieCollection.Add(c.Name, c);
               }
          }
          HttpContext.Current.Items.Add("CookieCollection", cookieCollection);
          Response.Cookies.Clear();
     }
    
void Application_PreSendRequestHeaders(object sender, EventArgs e) { if (HttpContext.Current.Items.Contains("CookieCollection")) { Dictionary<String, HttpCookie> cookieCollection = (Dictionary<String, HttpCookie>)HttpContext.Current.Items["CookieCollection"]; foreach(HttpCookie c in cookieCollection.Values){ HttpContext.Current.Response.Cookies.Add(c);
} } } </script>