vendredi 5 juin 2015

Expire Cache in Application After Few Seconds

We are looking for expiring the cache after few seconds. The back button of the browser should hit the server when the cache expires else it would fetch from cache.

HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddSeconds(10));
        HttpContext.Current.Response.AppendHeader("cache-control","no-cache");
        HttpContext.Current.Response.Cache.SetNoServerCaching();
        HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);

But this doesn't seem to work. Setting cache as no store disables cache when the page loads but we are not able to expire the cache after few seconds.

Aucun commentaire:

Enregistrer un commentaire