asp.netcachingoutputcacheektron

.NET OutputCache directive not working


I've been having strange cache issues and put together a very simple .NET page with an output cache directive. However, the page is not caching (the content updates on every refresh).

I have a simple, minimal site of our CMS (Ektron v. 9.0 SP2) installed on my local machine (Windows 7). Within this website project I created a simple page for testing the output cache. Here is the page code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CacheTest.aspx.cs" Inherits="CacheTest" %>
<%@ OutputCache Duration="3600" Location="Server" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Cache Test</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <p><%= DateTime.Now.ToString() %></p>
    </div>
    </form>
</body>
</html>

This page does not cache at all.

On our production site, the OutputCache in general does not work either, except on one test page which is configured exactly like the above. I cannot figure out why that one page is different, and is the only one that works on the dev server but when copied into the site running on my localhost, it does not work anymore.

I did notice that on our production site, using a master page seems to make the output cache not work, though in this localhost site I am not using a master page and it still does not work.

Where should I begin looking to troubleshoot this issue? I've looked through IIS settings and can't find any obvious settings to turn on/off page-level caching. I've also searched the web extensively and can't seem to find anyone else with this issue.


Solution

  • Microsoft has disabled output cache for pages that include cookies to prevent one user from getting a cached version of a page that was meant for another user.

    There is a workaround that removes cookies from the output. See https://support.episerver.com/hc/en-us/articles/115004119986-Output-Caching-Broken

    As an alternative, you could also use partial page caching by caching your user controls.