加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

ASP.NET OutputCache varyByParam在Web.config中不起作用

发布时间:2020-12-16 07:06:12 所属栏目:asp.Net 来源:网络整理
导读:我试图缓存一些昂贵的生成图表.所以我在Web.config中这样做了: caching outputCacheSettings outputCacheProfiles !-- 4 hours : 60 sec x 60 min x 4 hour = 14400 sec -- add name="ChartCacheProfile" duration="14400" varyByParam="none" / /outputCac
我试图缓存一些昂贵的生成图表.所以我在Web.config中这样做了:

<caching>
  <outputCacheSettings>
      <outputCacheProfiles>
          <!-- 4 hours : 60 sec x 60 min x 4 hour = 14400 sec -->
          <add name="ChartCacheProfile" duration="14400" varyByParam="none" />
      </outputCacheProfiles>
  </outputCacheSettings>
</caching>

我在我的控制器中添加了这个:

[OutputCache(CacheProfile="ChartCacheProfile")]
public ActionResult GenerateChart()

但是这不起作用……,结果仍然没有被缓存,并且Action总是被执行.这可能需要1分钟才能完成.

请注意,每次都会使用不同的参数调用url.该参数与正在生成的图表无关.这就是我把varyByParam =“none”的原因.

解决方法

我怀疑它确实是一个错误.对我有用的是在OutputCache属性中显式设置VaryByParam:

[OutputCache(CacheProfile="ChartCacheProfile",VaryByParam="None")]
public ActionResult GenerateChart()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读