Reputation: 303
I have already browsed through various questions on SO on iframe caching but haven't got the answer I am looking for.
We allow embedding of content uploaded on our web app using iframe embed code which looks something like this:
<iframe src="http://emdevcc5.mediapartner.com/embed.aspx?e=UkvpYFBUMZc=" style="height: 400px; width: 400px;" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" id="UkvpYFBUMZc="></iframe>
This code can be embedded anywhere in third party web pages like blogs, news articles etc. There is weird problem I am facing which as described here in this question. (The problem described in that question is not really important at the moment):
YUI dialog/panel not rendering correctly in IE iframe
That problem goes away whenever I clear browser cache from IE dev tools. That operation I believe clears cache of parent page which I don't think I can trigger from the code of of my iframe page.
So I am looking for work arounds to achieve this i.e. clearing cache of parent page. Since that embed code is not generated every time it is accessed - it is generated only once and then accessed multiple times - I can't really append some random timestamp at the end of src attribute. At least I don't think I can do it without involving javascript in the embed code.
I do have control over iframe content and I have added no-cache tags in my page head. Because of those tags, on debugging, I see that request is indeed getting served by the server. Still the problem goes away only on clearing the cache of parent page from IE dev tools. So I am not sure how I can trigger clearing of cache of the parent page.
Any ideas how I can solve this problem?
Upvotes: 0
Views: 1150
Reputation: 312
This depends if you are in control of the content. There are 2 tags you can put (ideally in the head of the page) that will tell the browser not to use a cached version. I use
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
Most sites will say this may or may not work but I have never had an issue with this on any browser.
Upvotes: 2
Reputation: 595
You are in control of the web page. So set the appropriate headers to prevent caching.
Here is a sample in PHP.
<?
header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
?>
You would put that at the top of your page.
Upvotes: 2