【发布时间】:2013-11-30 10:10:54
【问题描述】:
我遇到了一个问题,即输出缓存似乎不适用于我的 ASP.NET MVC 4 (EPiServer 7) 网站。
我的web.config 中有以下输出缓存配置文件:
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="PageOutput" enabled="true" duration="300" varyByParam="*" location="ServerAndClient" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
这是我对静态资源的输出缓存配置:
<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>
我的控制器被这样的输出缓存属性修饰:
[OutputCache(CacheProfile = "PageOutput")]
public class HomePageController : BasePageController<HomePage>
{ ...}
我在 perfmon 中查看以下计数器,但在访问主页时没有看到它们按预期增加:
\ASP.NET Apps v4.0.30319(__Total__)\Output Cache Entries\ASP.NET Apps v4.0.30319(__Total__)\Output Cache Hits
我也一直在使用tinyget 进行测试,如下所示:
tinyget -srv:mywebsite -uri:/ -threads:1 -loop:20
任何建议将不胜感激!
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 caching asp.net-web-api outputcache