【发布时间】:2014-11-13 06:54:11
【问题描述】:
我正在尝试为我们的公共站点设置全局服务器端输出缓存。我可以看到有一个 OutputCache 属性可以让您控制它。如果我像这样在 filterConfig 中全局注册它,这很好用
filters.Add(new OutputCacheAttribute() { Duration = 3600, VaryByParam = "*" });
问题是这会在客户端启用缓存,这会导致我们设置的一些重定向逻辑出现问题。所以我们需要
但是如果像这样将 location 属性设置为 Server
filters.Add(new OutputCacheAttribute() { Duration = 3600, VaryByParam = "*", Location = OutputCacheLocation.Server });
那么这会在某些带有子操作的页面上导致以下异常。
子操作的 OutputCacheAttribute 仅支持 Duration、VaryByCustom 和 VaryByParam 值。请不要为子操作设置 CacheProfile、Location、NoStore、SqlDependency、VaryByContentEncoding 或 VaryByHeader 值
有没有办法全局启用服务器端缓存?谁能解释为什么这不起作用?
【问题讨论】: