.NET OutputCache指令不起作用 [英] .NET OutputCache directive not working

查看:128
本文介绍了.NET OutputCache指令不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直遇到奇怪的缓存问题,并将一个非常简单的.NET页面与一个输出缓存指令组合在一起.但是,该页面未缓存(内容在每次刷新时更新).

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).

我在本地计算机(Windows 7)上安装了一个简单,最少的CMS(Ektron v.9.0 SP2)站点.在这个网站项目中,我创建了一个简单的页面来测试输出缓存.这是页面代码:

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>

此页面根本不缓存.

在我们的生产站点上,除了在与上面完全一样配置的一个测试页上之外,OutputCache通常也不起作用.我无法弄清楚为什么该页面与众不同,并且是唯一可在开发服务器上运行的页面,但是将其复制到在我的本地主机上运行的站点中后,它将不再起作用.

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.

我确实注意到,在我们的生产站点上,使用母版页似乎会使输出缓存不起作用,尽管在此localhost站点中我没有使用母版页,但仍然无法使用.

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.

我应该从哪里着手解决此问题?我浏览了IIS设置,找不到任何明显的设置来打开/关闭页面级缓存.我也已经在网上进行了广泛的搜索,但似乎找不到其他人遇到这个问题.

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.

推荐答案

Microsoft禁用了包含cookie的页面的输出缓存,以防止一个用户获取旨在供另一用户使用的页面的缓存版本.

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.

有一种解决方法,可以从输出中删除Cookie. 看 https://support.episerver.com/hc/zh-cn/articles/115004119986-Output-Caching-Broken

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.

这篇关于.NET OutputCache指令不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆