Sadiq
Sadiq

Reputation: 2289

Server-side equivalent of IE setting "Check for newer version of stored page"

I have a web app where the user can fill out or modify a form and save it, then return to it later to modify it if needed. After saving the form, all the values are stored in the database, and the form is populated using those values when the user visits it again.

It seems that every time the user returns to the form AFTER saving, the form will show its old state prior to saving until the user refreshes the page. This will happen every single time unless the user has the Internet Explorer setting for Check for newer version of stored page set to Every time I visit the webpage.

The problem only happens in Internet Explorer, there are no issues with any other browsers. I've tried setting the HTTP headers to prevent caching with no luck.

I've tried adding the meta tags <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Expires" content="-1"> to the page head, and I've also tried:

Response.Expires = -1; 
Response.AddHeader("Pragma", "no-cache"); 
Response.CacheControl = "No-cache";
Response.Cache.SetCacheability(HttpCacheability.NoCache); 

in the controller.

And here are the response headers:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Mon, 26 Aug 2013 20:10:33 GMT
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 3.0
Pragma: no-cache
Cache-Control: no-cache, no-store
Pragma: no-cache
Expires: -1
Content-Type: text/html; charset=utf-8
Content-Length: 66131
Connection: Close

Is there a way I can force IE to check for a new version of a stored page every time the user lands on that page? If not, is there a workaround for this issue in MVC3?

Thanks in advance!

Upvotes: 2

Views: 1606

Answers (2)

Jason Montgomery
Jason Montgomery

Reputation: 101

Our work around was been to pass a time stamp in the URL so that the page has a unique address every time and will not be displayed from the cache. The time stamp parameter is then ignored in the controller.

Upvotes: 3

EricLaw
EricLaw

Reputation: 57095

You failed to set the proper headers to prevent caching. What exactly did you try, and what were the headers in question (look with Fiddler).

In this article, I explain how IE's "Check for new versions" feature works, and as I say there:

The most important fact to keep in mind is that these four options impact the behavior when there are no caching headers on the HTTP responses; when caching headers are present, Internet Explorer will always respect them.

Upvotes: 0

Related Questions