I have created an ASP.NET 4 based website.
At first I ran the default site as it was generated by Visual Studio ASP.NET 4 Internet Application template. I just hit the Debug button, and IE was launched, it connected to http://localhost:1341/
and loaded the default welcome page of my website. Everything seemed fine, so I started to redesign the Index.cshtml.
After redesigning, I launched the website again. And while navigating, I noticed that if I click browser's Back button, I get the cached old version of the first page and I have to hit Refresh in the browser to get the new one.
So I added
<meta http-equiv="PRAGMA" content="NO-CACHE">
and
protected void Application_BeginRequest(object sender, EventArgs e)
{
// prevent caching
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
HttpContext.Current.Response.Cache.SetValidUntilExpires(false);
HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoStore();
}
to my website.
Then I cleared the IE cache using IE Options. I also cleaned my Local\Temp folder.
But still I got Result 304 in the IE developer tools Network tab when hitting Back button in the browser.
The only way to get the new redesigned page is to use Cache->Always refresh from server. I could do that for development purposes, but it is just messing my mind up - where does it get that very old page from always when I hit Back?
When debugging, in Visual Studio there appears a new tree item in the Solution Explorer. This new item is called Script documents. Under it, there is a Windows Internet Explorer item which contains localhost item ... and when I open it - yeah, that's the old page which is coming to IE when I hit Back button! Where does Visual Studio (or ASP.NET Dev server) store that "localhost" page?
How do I get rid of that stuck page and stop IE (or maybe also the ASP.Dev server) from caching my localhost/ front page? How do I delete that old page for good?
I hope, the new page won't be cached the same way, because I added to it...