什么会阻止 ASP.NET 进行输出缓存?

发布于 2024-08-23 05:31:23 字数 445 浏览 2 评论 0原文

我有一个 ASP.NET 应用程序,并且正在尝试输出缓存某个页面,但是对于每个请求,调试器仍然会调用 OnLoad 方法,并且我会收到 200 响应。

我已将输出缓存指令放置在页面上,如下所示:

<%@ OutputCache Duration="60" VaryByParam="None" %>

并确保我拥有 OutputCache 模块

<add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/>

并且还绕过了 URL 重写以防万一。我已经使用 Cassini 和 IIS 5.1 (XP) 尝试过此操作,但是该页面根本不缓存。

还有其他我没有考虑过的因素可能会影响此功能吗?

谢谢

I have an ASP.NET application, and am trying to output cache a certain page, however on every request, the debugger is still hitting the OnLoad method and I get a 200 response back.

I have placed the output cache directive on a page like so:

<%@ OutputCache Duration="60" VaryByParam="None" %>

And ensured I have the OutputCache module

<add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/>

And have also bypassed URL rewriting just in case. I have tried this using Cassini and IIS 5.1 (XP), however the page is not caching at all.

Are there any other factors which I have not looked at which could affect this feature?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆梦 2024-08-30 05:31:23

我也有同样的问题。我发现在处理我无法缓存的请求时调用了这行代码:

Response.Cache.SetCacheability(HttpCacheability.NoCache);

注释掉此代码使输出缓存再次开始工作。我猜想上面的行只会影响发送到客户端/浏览器的标头。确保在页面生命周期的任何时刻都不会执行类似的操作。

I had the same problem. I found this line of code being called while handling the request that I couldn't cache:

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Commenting this out made Output caching start working again. I would have guessed that the line above would only affect Headers sent to the client/browser. Make sure nothing like this is being executed at any point in the page life-cycle.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文