We have implemented a popup window as a modal dialog using the IE method:
window.showModalDialog('...aspx')
The target of the popup window is itself an ASP.Net web page.
Assume for the following steps that the popup has never been launched:
It's clear that the popup content is being cached because if at Step 4 we clear the temporary internet files the Page_Load event handler is executed the second time.
We have experimented with adding the following to the Head of the web page (as recommended by several other sources) but none of it seems to work.
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
We have also seen places where the use of these is discouraged
Can anyone help?
Navigate to the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings registry subkey. From the Edit menu, select New, DWORD Value. Enter a name of DisableCachingOfSSLPages, then press Enter. Double-click the new value, set it to 1 to disable caching of SSL pages, then click OK.
cache-control: no-cacheThis token is changed on the origin server whenever the resource is updated. When a user returns to a page with a 'no-cache' resource, the client will always have to connect to the origin server and compare the ETag on the cached resource with one on the server.
The Cache-Control header This header prevents all caching of a particular Web resource when the no-cache value is specified by an HTTP 1.1 server. Pages that are kept out of the cache aren't accessible until the browser can recontact the Web server. So, servers should use the Cache-Control header sparingly.
Add a timestamp querystring variable to the URL of the dialog content - number of ticks since 1/1/08 or something - IE will treat it as a new page and ignore the cache.
To clear cache add this in page load:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Given that the http-equiv directives don’t work (and arguably shouldn’t be used), and despite it unfortunately being in the hack category of solutions, I think we are going to have to go with this (posted by Greg)...
url = "<Some url with query string>"
var date = new Date();
window.showModalDialog(url + “&” + date.getTime(), ... );
It is strange that there is no definitive way to disable caching on these modal dialogs. I’m not sure whether using modal dialogs in web browsers is accepted as a "good idea" or not, but we are aware of at least some of the shortcomings and alternatives, but are just unfortunately unable to use them in this project.
Thanks for your suggestions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With