Using sql-server: Prevent caching on ASP MVC site running on IIS 7.5 on newest questions tagged sql-server – Stack Overflow

I have an ASP MVC 3 site running on IIS 7.5 and I cant prevent it from caching.

I have disabled the output caching in IIS by adding a ‘* Do Not Cache’ entry to the website and also added an action filter on the controller on result execute that prevents caching too (see code below) but when I use the site, it’s still caching. I have deleted all history and cookies etc from Internet Explorer and Firefox but I still see old data.

Does anyone have any ideas or suggestions on what else I can do to try and prevent this?

Thanks in advance,

James

UPDATE

I have dug further using the SQL profiler and it seems to be the SQL server caching the query. Could this be the case?

2nd UPDATE

I now know if definitley NOT SQL caching, now looking at IIS and MVC

SOLVED!!!

It was NHibernate!

It was using the same session for every call rather than a session per request.

    public override void OnResultExecuting(ResultExecutingContext filterContext)
    {
        filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
        filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
        filterContext.HttpContext.Response.Cache.SetRevalidation    (HttpCacheRevalidation.AllCaches);
        filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        filterContext.HttpContext.Response.Cache.SetNoStore();

        base.OnResultExecuting(filterContext);
    }

See Answers


source: http://stackoverflow.com/questions/5978350/prevent-caching-on-asp-mvc-site-running-on-iis-7-5
Using sql-server: using-sql-server



online applications demo