Created
June 24, 2014 14:45
-
-
Save feanz/5878289bcdab239b26a6 to your computer and use it in GitHub Desktop.
No Cache Action filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NoCacheAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) | |
{ | |
base.OnActionExecuted(actionExecutedContext); | |
if (actionExecutedContext.Response.IsSuccessStatusCode) | |
{ | |
var cc = new System.Net.Http.Headers.CacheControlHeaderValue(); | |
cc.NoStore = true; | |
cc.NoCache = true; | |
cc.Private = true; | |
cc.MaxAge = TimeSpan.Zero; | |
actionExecutedContext.Response.Headers.CacheControl = cc; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment