0

Is it possible to tell IE from front-end/back-end code to do the following settings?

check newer versions of page every time page is visited

disable IE caching

I've tried adding the following headers:

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
<meta http-equiv="cache-control" content="no-store"> 

but it still doesn't work since I have to set that the page be checked for newer versions of the page (see the first image).

This is a .NET MVC app

Justin
  • 1
  • 2
  • I agree with Athanasios Kataras's answer. How do you check if the page is cached? You can use F12 dev tools to check cache: https://i.stack.imgur.com/4ucJj.png. Besides, I find some other threads you can refer to. You can also check [this answer](https://stackoverflow.com/questions/12948156/asp-net-mvc-how-to-disable-automatic-caching-option/12964123#12964123) and [this thread](https://stackoverflow.com/questions/1160105/disable-browser-cache-for-entire-asp-net-website). – Yu Zhou Feb 19 '21 at 03:04

1 Answers1

1

For MVC it is actually pretty easy:

Response.Cache.SetCacheability(HttpCacheability.NoCache);  
Response.Cache.AppendCacheExtension("no-store, must-revalidate");
Response.AppendHeader("Pragma", "no-cache"); 
Response.AppendHeader("Expires", "0"); 

The meta headers are totally unreliable: Using <meta> tags to turn off caching in all browsers?

For global setting in your global.asax:

void Application_PreSendRequestHeaders(Object sender, EventArgs e)
{
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
}
Athanasios Kataras
  • 20,791
  • 3
  • 24
  • 45