Stop IE from caching iframe opened via jquery modal dialog
UPDATED: Found answer. Cannot submit my own answer for 7 more hours... See comments.
I'm opening a dialog as follows:
url = 'edit/MyPage.aspx?appid=3&value=4&' + date.getTime();
$('#modalIFrame').attr('src', url);
$('#modalDiv').dialog('open');
The iframe has a form with a few fields (checkboxes, dropdowns, textareas). In Chrome, everything is working flawelessly. In IE it caches very persistently and annoyingly. Even shift+refresh doesn't help. So if I open the dialog, make changes, hit submit, then refresh the page all the data looks right. However,开发者_JAVA技巧 when I click the edit button to open the dialog, it's the previous data (The data is pulled using an ajax call to a WCF service) I've even waited a couple hours for my session to expire, no luck.
As you can see above, I tried a trick I found here to trick IE into thinking it's a new page. This doesn't work. I also added the following code to the Page_Load of the page in the iframe:
Response.Cache.SetCacheability(HttpCacheability.NoCache)
and the following meta tags to the HTML:
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="0">
I'm completely lost here, any ideas would be appreciated.
Okay I discovered it was the WCF service that was being cached in IE (doesn't make sense to me, but whatever). I added a timestamp to the ajax call and now it works!
data: { "appid": appid, "serverid": serverid, "timestamp": date.getTime() },
精彩评论