小编Jam*_*esF的帖子

为什么输出缓存不能用于我的ASP.NET MVC 4应用程序?

我遇到的问题是输出缓存似乎不适用于我的ASP.NET MVC 4(EPiServer 7)网站.

我在我的输出缓存配置文件中有以下内容web.config:

<caching>
  <outputCacheSettings>
    <outputCacheProfiles>
      <add name="PageOutput" enabled="true" duration="300" varyByParam="*" location="ServerAndClient" />
    </outputCacheProfiles>
  </outputCacheSettings>
</caching>
Run Code Online (Sandbox Code Playgroud)

这是静态资源的输出缓存配置:

<caching>
  <profiles>
    <add extension=".gif" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
    <add extension=".png" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
    <add extension=".js" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
    <add extension=".css" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="00:01:00" location="Any" />
    <add extension=".jpg" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
    <add extension=".jpeg" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="00:01:00" location="Any" />
  </profiles>
</caching>
Run Code Online (Sandbox Code Playgroud)

我的控制器装饰有输出缓存属性,如下所示:

[OutputCache(CacheProfile = "PageOutput")]
public class HomePageController : BasePageController<HomePage>
{ ...}
Run Code Online (Sandbox Code Playgroud)

我在perfmon中观察以下计数器,但在访问主页时看不到它们按预期增加:

  • \ASP.NET …

asp.net-mvc caching outputcache asp.net-mvc-4 asp.net-web-api

13
推荐指数
1
解决办法
1万
查看次数