[ACCEPTED]-How do I clear the cache of an iFrame?-html
Accepted answer
The first choice is probably to control 6 browser caching for the iframe page from 5 your web server either with HTTP headers 4 or with <meta>
tags (see reference).
<meta HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
If you can't change 3 those, then you can set a .src
in the iframe 2 that has a different query parameter each 1 time to go around caching.
For example:
iframeObj.src = "http://www.example.com/page/myframe.html?random=" + (new Date()).getTime() + Math.floor(Math.random() * 1000000);
This is something you should do on the server 1 side, controlled via HTTP headers like so:
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sun, 29 Jul 2012 00:00:00 GMT"); // some day in the past
You could do something like
<iframe src="<?php echo $url.'#nocache'.time(); ?>">
#document</iframe>
Which would allow 3 for GET parameters in the URL without also 2 having to worry about whether to use ? or 1 & for your random.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.