This is discouraged though. You should rely on the ASP.net caching mechanisms as described in this article
Created
December 11, 2012 07:41
-
-
Save juristr/4256627 to your computer and use it in GitHub Desktop.
ASP.net MVC: Completely Disable Caching
This file contains hidden or 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 NoCacheGlobalActionFilter : ActionFilterAttribute | |
{ | |
public override void OnResultExecuting(ResultExecutingContext filterContext) | |
{ | |
//IE: http://support.microsoft.com/kb/316431 | |
if (!(filterContext.Result is FileResult)) | |
{ | |
HttpCachePolicyBase cache = filterContext.HttpContext.Response.Cache; | |
cache.SetCacheability(HttpCacheability.NoCache); | |
} | |
base.OnResultExecuting(filterContext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment