设置缓存超时Sitecore 8.1

如何在sitecore 8.1中设置渲染的缓存超时?

我应用了以下链接中建议的代码,但没有奏效.

http://www.reinoudvandalen.nl/blog/add-sliding-expiration-on-sitecore-rendering-cache/

我也尝试在控制器的动作方法中添加以下代码,但仍然无法正常工作.

RenderingContext.CurrentOrNull.Rendering.Caching.Timeout = new TimeSpan(0, 0, 10);

有没有其他方法可以尝试,所以我可以为每个渲染设置超时?

最佳答案 您可以使用此属性(在操作上方)来设置缓存超时:

 [OutputCache(Duration = 200)]
 public ActionResult ProductDetail()
 {
   ....
点赞