Skip to content

Instantly share code, notes, and snippets.

@Jeavon
Created April 30, 2015 19:33
Show Gist options
  • Save Jeavon/be9f8ca38cf8996ffede to your computer and use it in GitHub Desktop.
Save Jeavon/be9f8ca38cf8996ffede to your computer and use it in GitHub Desktop.
ConfigDurationOutputCacheAttribute.cs
namespace MyProj.Common.Cache
{
using System.Web.Configuration;
using System.Web.Mvc;
using System.Web.UI;b
using DevTrends.MvcDonutCaching;
public class ConfigDurationOutputCacheAttribute : DonutOutputCacheAttribute
{
public ConfigDurationOutputCacheAttribute()
{
this.Duration = int.Parse(WebConfigurationManager.AppSettings["OutputCacheDuration"]);
this.VaryByCustom = "url";
this.Location = OutputCacheLocation.Server;
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
var cookie = filterContext.HttpContext.Request.Cookies["UMB_PREVIEW"];
if (cookie == null || string.IsNullOrWhiteSpace(cookie.Value))
{
base.OnActionExecuting(filterContext);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment